Subbu1304 commited on
Commit
0e993a7
Β·
verified Β·
1 Parent(s): 77f7df7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -1,14 +1,15 @@
1
  import gradio as gr
2
  import speech_recognition as sr
3
- import pyttsx3
 
4
 
5
- # Initialize the speech engine
6
- engine = pyttsx3.init()
7
-
8
- # Function to speak text
9
  def speak(text):
10
- engine.say(text)
11
- engine.runAndWait()
 
 
 
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():