Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
7 |
|
8 |
prompt = "Type and press Enter"
|
9 |
|
10 |
|
11 |
def record_text(audio_file,api_key):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
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(".")
|