这个错误是什么 - "IOError: [Errno 2] 没有这样的文件或目录: 'audio.flac' ",我正在尝试使用谷歌语音识别 API for Python



基本上我想将语音转换为文本,所以我试图使用python的谷歌语音识别api。

这是我要运行的代码-

from pygsr import Pygsr
speech = Pygsr()
speech.record(3) # duration in seconds (3)
phrase, complete_response = speech.speech_to_text('es_ES')
print phrase # This is the required output

我已经正确安装了所有的模块,所以可能没有什么问题的模块,我得到以下错误-

Traceback (most recent call last):
  File "C:/Python/google_voice.py", line 4, in <module>
    phrase, complete_response = speech.speech_to_text('es_ES') # select the language
  File "C:/Pythonpygsr__init__.py", line 49, in speech_to_text
    audio = open(file_upload, "rb").read()
IOError: [Errno 2] No such file or directory: 'audio.flac'
谁能告诉我我错过了什么?或者请建议任何好的python语音到文本的转换方法。

您错过了将记录的wav转换为flv的sox工具,您可以在pygsr源代码中看到一行:system("sox %s -t wav -r 48000 -t flac %s。Flac"% (self。文件,self.file))。确保sox可以为您工作,并且它可以创建flac文件。

最新更新