Python语音识别工作非常缓慢,并且有很大的时间延迟
如何使语音识别更快地倾听和响应。它识别准确,但有很多时间滞后和延迟。请提供解决方案,或者他们可能是一些阈值设置,我们可以通过这些设置限制其在特定迭代中的听觉时间 以下是我使用的代码:Python语音识别工作非常缓慢,并且有很大的时间延迟,python,machine-learning,speech-recognition,Python,Machine Learning,Speech Recognition,如何使语音识别更快地倾听和响应。它识别准确,但有很多时间滞后和延迟。请提供解决方案,或者他们可能是一些阈值设置,我们可以通过这些设置限制其在特定迭代中的听觉时间 以下是我使用的代码: def speak(text): tts=gTTS(text=text,lang="en") date_string = datetime.datetime.now().strftime("%d%m%Y%H%M%S") filename="hello"+date_string+".mp3"
def speak(text):
tts=gTTS(text=text,lang="en")
date_string = datetime.datetime.now().strftime("%d%m%Y%H%M%S")
filename="hello"+date_string+".mp3"
tts.save(filename)
playsound.playsound(filename)
def getAudio():
r=sr.Recognizer()
with sr.Microphone() as source:
audio=r.listen(source)
said=""
try:
said=r.recognize_google(audio)
print(said)
except:
print("sorry can not understand")
return said
while True:
text=getAudio()
if "hello" in text:
speak("hello there,how are you")
if "your name" in text:
speak("my name is bot")
if "quit" in text:
speak("Goodbye see you again!")
break