Spaces:
Running
Running
Update qa.py
Browse files
qa.py
CHANGED
@@ -18,7 +18,6 @@ def transcribe_audio_deepgram(local_audio_path: str) -> str:
|
|
18 |
raise ValueError("Deepgram API key not found in environment variables.")
|
19 |
|
20 |
url = "https://api.deepgram.com/v1/listen?model=nova-2&smart_format=true"
|
21 |
-
# For WAV -> "audio/wav". If user uploads MP3, you'd use "audio/mpeg".
|
22 |
headers = {
|
23 |
"Authorization": f"Token {DEEPGRAM_API_KEY}",
|
24 |
"Content-Type": "audio/wav"
|
@@ -84,6 +83,6 @@ def handle_qa_exchange(user_question: str) -> (bytes, str):
|
|
84 |
audio_file_path = generate_audio_mp3(answer_text, "John") # always John
|
85 |
with open(audio_file_path, "rb") as f:
|
86 |
audio_bytes = f.read()
|
87 |
-
os.remove(audio_file_path)
|
88 |
|
89 |
-
return (audio_bytes, answer_text)
|
|
|
18 |
raise ValueError("Deepgram API key not found in environment variables.")
|
19 |
|
20 |
url = "https://api.deepgram.com/v1/listen?model=nova-2&smart_format=true"
|
|
|
21 |
headers = {
|
22 |
"Authorization": f"Token {DEEPGRAM_API_KEY}",
|
23 |
"Content-Type": "audio/wav"
|
|
|
83 |
audio_file_path = generate_audio_mp3(answer_text, "John") # always John
|
84 |
with open(audio_file_path, "rb") as f:
|
85 |
audio_bytes = f.read()
|
86 |
+
os.remove(audio_file_path)
|
87 |
|
88 |
+
return (audio_bytes, answer_text)
|