【问题标题】:How to perform realtime speech recognition using google speech recognition如何使用谷歌语音识别执行实时语音识别
【发布时间】: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))

我是一名学生,正在做一个学术项目。非常感谢任何帮助。非常感谢。

【问题讨论】:

    标签: python speech-recognition


    【解决方案1】:

    您可以将 interimResults 参数设置为 True https://cloud.google.com/speech-to-text/docs/basics

    如果您正在寻找可以克隆并开始使用 Speech API 的环境,您可以查看 realtime-transcription-playground 存储库。

    【讨论】:

      猜你喜欢
      • 2016-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多