Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ client = Groq(api_key=GROQ_API_KEY)
|
|
13 |
|
14 |
# Function to convert text to speech using gTTS and return the audio path
|
15 |
def text_to_speech(text):
|
16 |
-
tts = gTTS(text)
|
17 |
response_audio_path = "response.mp3"
|
18 |
tts.save(response_audio_path)
|
19 |
return response_audio_path
|
@@ -46,8 +46,11 @@ def chatbot(audio):
|
|
46 |
# Step 3: Convert response text to speech and return audio
|
47 |
response_audio_path = text_to_speech(response)
|
48 |
|
49 |
-
#
|
50 |
-
|
|
|
|
|
|
|
51 |
|
52 |
# Gradio interface for the chatbot
|
53 |
interface = gr.Interface(
|
|
|
13 |
|
14 |
# Function to convert text to speech using gTTS and return the audio path
|
15 |
def text_to_speech(text):
|
16 |
+
tts = gTTS(text=text, lang='en')
|
17 |
response_audio_path = "response.mp3"
|
18 |
tts.save(response_audio_path)
|
19 |
return response_audio_path
|
|
|
46 |
# Step 3: Convert response text to speech and return audio
|
47 |
response_audio_path = text_to_speech(response)
|
48 |
|
49 |
+
# Ensure the audio file exists and return text + audio response
|
50 |
+
if os.path.exists(response_audio_path):
|
51 |
+
return response, response_audio_path
|
52 |
+
else:
|
53 |
+
return response, None # Fallback in case the audio file wasn't generated
|
54 |
|
55 |
# Gradio interface for the chatbot
|
56 |
interface = gr.Interface(
|