speech_recognition
speech_recognition copied to clipboard
speech_recognition.WaitTimeoutError
- I don't know why this issue occurs but its something related to phrase_time_limit. I've set it to 5.
- This is the code snippet containing the phrase- def takecommand(): r = sr.Recognizer() with sr.Microphone() as source: print("Listening...") r.pause_threshold = 1 audio = r.listen(source,timeout=1,phrase_time_limit=5)
I can't tell much more like the template but all i can supply is the code... I was following tutorials btw https://www.youtube.com/watch?v=EztlAyuOg6o&list=PLq_SHLFD-pSD_LeiV2dyAHgED7PDF48Jq&index=3
import pyttsx3 import speech_recognition as sr import datetime import os
engine = pyttsx3.init('sapi5') voices = engine.getProperty('voices') engine.setProperty('voices', voices[0].id)
def speak(audio): engine.say(audio) print(audio) engine.runAndWait()
def takecommand(): r = sr.Recognizer() with sr.Microphone() as source: print("Listening...") r.pause_threshold = 1 audio = r.listen(source,timeout=1,phrase_time_limit=5)
try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"User Said: {query}")
except Exception as e:
speak("Say that again please")
return "none"
return query
def wish(): hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<=12:
speak("Good Morning")
elif hour>12 and hour<18:
speak("Good Afternoon")
else:
speak("Good Evening")
speak("I am Jarvis. Please tell me how I may help You")
if name == "main": wish() while True:
query = takecommand().lower()
#logic for tasks
if "open notepad" in query:
npath = "C:\\Windows\\System32\\notepad.exe"
os.startfile(npath)
audio = r.listen(source,timeout=6,phrase_time_limit=5) dude set timeout greater than 5 if this does not work then
audio = r.record(source,duration=1,phrase_time_limit=5) try this thi will definetily work!
Hi! Thanks btw. I finished this project a long time ago but am still looking for ways to optimize it. This might just help 😂
On Sun, Aug 29, 2021, 4:20 PM MrcoderGod @.***> wrote:
audio = r.listen(source,timeout=6,phrase_time_limit=5) dude set timeout greater than 5 if this does not work then
audio = r.record(source,duration=1,phrase_time_limit=5) try this thi will definetily work!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/576#issuecomment-907770188, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVDGJJ2BCU4NGHZBAJ37DT3T7IGGZANCNFSM5BUALQZQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.