Spaces:
Runtime error
Runtime error
DSatishchandra
commited on
Commit
•
b6e0bda
1
Parent(s):
db6fb7c
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import speech_recognition as sr
|
3 |
from gtts import gTTS
|
4 |
import os
|
|
|
5 |
from transformers import pipeline
|
6 |
|
7 |
# Initialize recognizer for speech recognition
|
@@ -35,7 +36,9 @@ def recognize_speech(audio):
|
|
35 |
# Using gTTS to respond back with speech
|
36 |
tts = gTTS(text=response, lang='en')
|
37 |
tts.save("response.mp3")
|
38 |
-
|
|
|
|
|
39 |
|
40 |
return response
|
41 |
except Exception as e:
|
|
|
2 |
import speech_recognition as sr
|
3 |
from gtts import gTTS
|
4 |
import os
|
5 |
+
from playsound import playsound # Import playsound library
|
6 |
from transformers import pipeline
|
7 |
|
8 |
# Initialize recognizer for speech recognition
|
|
|
36 |
# Using gTTS to respond back with speech
|
37 |
tts = gTTS(text=response, lang='en')
|
38 |
tts.save("response.mp3")
|
39 |
+
|
40 |
+
# Play the MP3 response using playsound
|
41 |
+
playsound("response.mp3")
|
42 |
|
43 |
return response
|
44 |
except Exception as e:
|