mirror of
https://github.com/maglore9900/max_headroom.git
synced 2025-06-06 19:45:31 +00:00
.
This commit is contained in:
parent
fea8e32499
commit
d1d412945b
1
main.py
1
main.py
@ -10,7 +10,6 @@ graph = agent.Agent()
|
||||
|
||||
|
||||
while True:
|
||||
print("Listening...")
|
||||
text = sp.listen()
|
||||
if text and "max" in text.lower():
|
||||
response = loop.run_until_complete(graph.invoke_agent(text))
|
||||
|
@ -56,21 +56,28 @@ class Speak:
|
||||
|
||||
def listen(self):
|
||||
with self.microphone as source:
|
||||
#! Adjust for ambient noise
|
||||
# Adjust for ambient noise
|
||||
self.recognizer.adjust_for_ambient_noise(source, duration=1)
|
||||
|
||||
print("Listening...")
|
||||
try:
|
||||
#! added 5 second timeout so ambient noise detection can compensate for music that started playing
|
||||
# Listen with a 5-second timeout
|
||||
audio = self.recognizer.listen(source, timeout=5)
|
||||
try:
|
||||
text = self.recognizer.recognize_google(audio)
|
||||
print("You said: ", text)
|
||||
return text
|
||||
except:
|
||||
pass
|
||||
# except sr.UnknownValueError:
|
||||
# print("Sorry, I didn't get that.")
|
||||
# except sr.RequestError as e:
|
||||
# print("Sorry, I couldn't request results; {0}".format(e))
|
||||
except sr.UnknownValueError:
|
||||
print("Sorry, I didn't get that.")
|
||||
return None
|
||||
except sr.RequestError as e:
|
||||
print("Sorry, I couldn't request results; {0}".format(e))
|
||||
return None
|
||||
except sr.WaitTimeoutError:
|
||||
print("Timeout. No speech detected.")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
||||
def stream_output(self, text):
|
||||
import urllib.parse
|
||||
|
Loading…
x
Reference in New Issue
Block a user