关于我在项目中遇到的一个问题,我有一个问题。它被认为是通过言语与使用者交流的。我正在使用google speech api向系统发出命令。它需要一些时间来处理命令,然后响应back.The问题是,它需要比预期更长的暂停时间(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))我是一名学生,正在做一个学术项目。任何帮助都是非常感谢的。非常感谢。
发布于 2021-07-08 15:05:33
您可以将interimResults参数设置为True https://cloud.google.com/speech-to-text/docs/basics。
如果您正在寻找一个可以克隆并开始使用Speech API的环境,您可以查看realtime-transcription-playground存储库。
https://stackoverflow.com/questions/46835899
复制相似问题