Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import speech_recognition as sr
|
| 3 |
-
import
|
|
|
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
engine = pyttsx3.init()
|
| 7 |
-
|
| 8 |
-
# Function to speak text
|
| 9 |
def speak(text):
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Function to listen to user voice input using SpeechRecognition
|
| 14 |
def listen():
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import speech_recognition as sr
|
| 3 |
+
from gtts import gTTS
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
+
# Function to speak text using Google Text-to-Speech
|
|
|
|
|
|
|
|
|
|
| 7 |
def speak(text):
|
| 8 |
+
tts = gTTS(text=text, lang='en')
|
| 9 |
+
# Save the speech to a temporary audio file
|
| 10 |
+
tts.save("output.mp3")
|
| 11 |
+
# Play the saved audio file
|
| 12 |
+
os.system("mpg321 output.mp3")
|
| 13 |
|
| 14 |
# Function to listen to user voice input using SpeechRecognition
|
| 15 |
def listen():
|