28 lines
738 B
Python
28 lines
738 B
Python
|
|
print("Processing...")
|
|
text = r.recognize_whisper(audio, language="english")
|
|
print(f"Whisper thinks you said {text}")
|
|
|
|
#TODO: Check for Apollo
|
|
|
|
def callback(recognizer, audio):
|
|
try:
|
|
pass
|
|
except sr.UnknownValueError:
|
|
print("Whisper could not understand audio")
|
|
except sr.RequestError as e:
|
|
print("Could not request results from Whisper")
|
|
|
|
|
|
|
|
r = sr.Recognizer()
|
|
m = sr.Microphone()
|
|
with m as source:
|
|
r.adjust_for_ambient_noise(source) # we only need to calibrate once, before we start listening
|
|
|
|
stop_listening = r.listen_in_background(m, callback)
|
|
|
|
print("Listening...")
|
|
while True:
|
|
time.sleep(0.1) # we're not listening anymore,
|
|
# print('1') |