我正在从事一个涉及使用 SpeechRecognition 模块进行语音识别的项目。为了提高语音识别能力,我想做的一件事是能够尽快输出已识别的单词。我希望它类似于你对谷歌翻译说话的时候,只要你说一个词,它就会在屏幕上输出它,让你知道你已经说过了。
我尝试过的一些事情是拥有一个存储单独录音的数组,并让语音识别遍历该数组,识别每个录音然后输出。这不起作用,因为不同的词需要不同的时间才能说出来。
我进一步研究了 SpeechRecognition 模块提供给我的用于语音识别的 Google API,并想了解如何通过在某些地方添加打印语句来调整实际库以实现目标。我不知道该放在哪里,因为我是语音识别的初学者,而且我对 Google Speech Recognition API 不太了解。
这是google api代码,它访问云做sr。
def recognize_google(self, audio_data, key=None, language="en-US", show_all=False):
"""
Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using the Google Speech Recognition API.
The Google Speech Recognition API key is specified by ``key``. If not specified, it uses a generic key that works out of the box. This should generally be used for personal or testing purposes only, as it **may be revoked by Google at …Run Code Online (Sandbox Code Playgroud)