我想要一个快速的离线语音识别器(如 vosk 或 sphinx)作为谷歌语音识别的唤醒词,所以它并不总是能听到我们说的话。
想要唤醒这个词:
def takeCommand():
# mic input
r = sr.Recognizer()
with sr.Microphone() as source:
print("Hearing...")
# r.pause_threshold = 1
r.chunk_size = 2048
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
try:
print("Recognizing....")
query = r.recognize_google(audio, language='en-in')
print(f"You said: {query}\n")
except Exception as e:
print(e)
print("Say that again please...")
return "None"
return query