Vihang28 commited on
Commit
036a67e
1 Parent(s): 5a85225

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -3,18 +3,20 @@ from pydub import AudioSegment
3
  import gradio as gr
4
  from os import path
5
  import requests
6
- import openai
7
 
8
  prompt = "Type and press Enter"
9
 
10
 
11
  def record_text(audio_file,api_key):
12
- openai.api_key = api_key
13
- audio_file = open(audio_file, "rb")
14
- transcript = openai.Audio.transcribe("whisper-1", audio_file)
15
- text = transcript['text']
16
- return text
17
- # r = sr.Recognizer()
 
 
18
 
19
  # sound = audio_file
20
  # sound_type = sound.split(".")
 
3
  import gradio as gr
4
  from os import path
5
  import requests
6
+ from openai
7
 
8
  prompt = "Type and press Enter"
9
 
10
 
11
  def record_text(audio_file,api_key):
12
+ model_id = 'whisper-1'
13
+ media_file = open(audio_file, 'rb')
14
+ response = openai.Audio.transcribe(
15
+ api_key=api_key,
16
+ model=model_id,
17
+ file=media_file
18
+ )
19
+ return response.data['text']
20
 
21
  # sound = audio_file
22
  # sound_type = sound.split(".")