【发布时间】:2021-07-08 15:05:33
【问题描述】:
我有一个关于我的项目面临的问题的问题。它应该通过语音与使用进行交流。我正在使用谷歌语音 api 向系统发出命令。处理命令需要一些时间然后响应。问题是,它需要比预期更长的暂停时间(6-8 秒)然后继续回答。
对于我的程序,我需要实时语音识别,以便系统在我完成问题后立即响应。我的问题是,是否有将每个单词在说话时发送到 API,而不是在完成后发送整个句子。我的代码如下:
import speech_recognition as sr
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
try:
print("You said " + r.recognize_google(audio))
except sr.UnknownValueError:
print("Ooops! Could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
我是一名学生,正在做一个学术项目。非常感谢任何帮助。非常感谢。
【问题讨论】: