speech_recognition
speech_recognition copied to clipboard
How to make google speech API keep listening even if user stop talking
Im using Google Speech API
The system shall work as the following:
1- When the user click "Start" button, the System shall start recording
2- When the user click "Stop" button, the System shall stop recording and display the result
Her is my "Start" button definition
def Recite():
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
try:
global s
s = r.recognize_google(audio,language ="ar-AR")
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
title4= tk.Label(text ="غير مفهوم ", foreground="red")
title4.grid(column=0,row=16)
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
title5= tk.Label(text ="حدث خطأ ", foreground="red")
title5.grid(column=0,row=16)
the issue is, my system stops recognition automatically when the user stops talking how can I stop only if the user does action (Click the "Stop" button)?
Put your function inside a infinite loop.
Im using Google Speech API
The system shall work as the following:
1- When the user click "Start" button, the System shall start recording
2- When the user click "Stop" button, the System shall stop recording and display the result
Her is my "Start" button definition
def Recite(): r = sr.Recognizer() with sr.Microphone() as source: audio = r.listen(source) try: global s s = r.recognize_google(audio,language ="ar-AR") except sr.UnknownValueError: print("Google Speech Recognition could not understand audio") title4= tk.Label(text ="غير مفهوم ", foreground="red") title4.grid(column=0,row=16) except sr.RequestError as e: print("Could not request results from Google Speech Recognition service; {0}".format(e)) title5= tk.Label(text ="حدث خطأ ", foreground="red") title5.grid(column=0,row=16)
the issue is, my system stops recognition automatically when the user stops talking how can I stop only if the user does action (Click the "Stop" button)?