Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,12 +15,13 @@ def speech_to_text(audio):
|
|
| 15 |
return "No audio file uploaded."
|
| 16 |
|
| 17 |
try:
|
| 18 |
-
# Transcribe the audio to text using OpenAI's Whisper API
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
text = response['text']
|
| 25 |
return text
|
| 26 |
except Exception as e:
|
|
|
|
| 15 |
return "No audio file uploaded."
|
| 16 |
|
| 17 |
try:
|
| 18 |
+
# Transcribe the audio to text using OpenAI's Whisper API via the new method
|
| 19 |
+
with open(audio, "rb") as audio_file:
|
| 20 |
+
response = openai.Audio.transcribe(
|
| 21 |
+
model="whisper-1", # Use the appropriate model for transcription
|
| 22 |
+
file=audio_file,
|
| 23 |
+
language="ta" # Specify the language as Tamil
|
| 24 |
+
)
|
| 25 |
text = response['text']
|
| 26 |
return text
|
| 27 |
except Exception as e:
|