Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import os
|
|
| 6 |
import soundfile as sf
|
| 7 |
from f5_tts.api import F5TTS
|
| 8 |
|
| 9 |
-
# 1. Setup Configuration
|
| 10 |
GROQ_API_KEY = "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"
|
| 11 |
voice_file = "my_voice_fixed.wav"
|
| 12 |
|
|
@@ -44,6 +44,7 @@ def get_ai_answer(question):
|
|
| 44 |
},
|
| 45 |
timeout=15
|
| 46 |
)
|
|
|
|
| 47 |
return response.json()["choices"][0]["message"]["content"].strip()
|
| 48 |
except Exception as e:
|
| 49 |
print(f"Parsing Exception: {e}")
|
|
@@ -65,6 +66,7 @@ def clone_and_speak(text):
|
|
| 65 |
|
| 66 |
if os.path.exists(unique_filename) and os.path.getsize(unique_filename) > 0:
|
| 67 |
data, samplerate = sf.read(unique_filename)
|
|
|
|
| 68 |
sf.write(unique_filename, data, 24000, format='WAV', subtype='PCM_16')
|
| 69 |
return unique_filename
|
| 70 |
else:
|
|
|
|
| 6 |
import soundfile as sf
|
| 7 |
from f5_tts.api import F5TTS
|
| 8 |
|
| 9 |
+
# 1. Setup Configuration
|
| 10 |
GROQ_API_KEY = "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"
|
| 11 |
voice_file = "my_voice_fixed.wav"
|
| 12 |
|
|
|
|
| 44 |
},
|
| 45 |
timeout=15
|
| 46 |
)
|
| 47 |
+
# CRITICAL FIX: Restored the [0] index to read the Groq response array correctly
|
| 48 |
return response.json()["choices"][0]["message"]["content"].strip()
|
| 49 |
except Exception as e:
|
| 50 |
print(f"Parsing Exception: {e}")
|
|
|
|
| 66 |
|
| 67 |
if os.path.exists(unique_filename) and os.path.getsize(unique_filename) > 0:
|
| 68 |
data, samplerate = sf.read(unique_filename)
|
| 69 |
+
# Re-write wav file parameters to match Gradio standards
|
| 70 |
sf.write(unique_filename, data, 24000, format='WAV', subtype='PCM_16')
|
| 71 |
return unique_filename
|
| 72 |
else:
|