Spaces:
Build error
Build error
DSatishchandra
commited on
Commit
•
2930d07
1
Parent(s):
77c2b9f
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
import speech_recognition as sr
|
2 |
-
import
|
|
|
3 |
from transformers import pipeline
|
4 |
-
import random
|
5 |
-
|
6 |
-
# Initialize the speech engine
|
7 |
-
engine = pyttsx3.init()
|
8 |
|
9 |
# Menu data from the second image (hardcoded for simplicity)
|
10 |
menu = {
|
@@ -21,10 +18,11 @@ menu = {
|
|
21 |
# Initialize the speech recognition
|
22 |
recognizer = sr.Recognizer()
|
23 |
|
24 |
-
# Function to speak a text using
|
25 |
def speak(text):
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
# Function to listen to user's voice
|
30 |
def listen():
|
|
|
1 |
import speech_recognition as sr
|
2 |
+
from gtts import gTTS
|
3 |
+
import os
|
4 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# Menu data from the second image (hardcoded for simplicity)
|
7 |
menu = {
|
|
|
18 |
# Initialize the speech recognition
|
19 |
recognizer = sr.Recognizer()
|
20 |
|
21 |
+
# Function to speak a text using Google Text-to-Speech (gTTS)
|
22 |
def speak(text):
|
23 |
+
tts = gTTS(text=text, lang='en')
|
24 |
+
tts.save("output.mp3")
|
25 |
+
os.system("mpg321 output.mp3") # For environments that support audio playback
|
26 |
|
27 |
# Function to listen to user's voice
|
28 |
def listen():
|