Python 2.7 这个错误是什么;IOError:[Errno 2]没有这样的文件或目录:';audio.flac'&引用;,我正在尝试使用用于python的google语音识别api

Python 2.7 这个错误是什么;IOError:[Errno 2]没有这样的文件或目录:';audio.flac'&引用;,我正在尝试使用用于python的google语音识别api,python-2.7,32-bit,voice-recognition,speech-to-text,ioerror,Python 2.7,32 Bit,Voice Recognition,Speech To Text,Ioerror,基本上我想将语音转换为文本,所以我尝试使用用于python的google语音识别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 我已经正确安

基本上我想将语音转换为文本,所以我尝试使用用于python的google语音识别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:/Python\pygsr\__init__.py", line 49, in speech_to_text
    audio = open(file_upload, "rb").read()
IOError: [Errno 2] No such file or directory: 'audio.flac'
回溯(最近一次呼叫最后一次):
文件“C:/Python/google_voice.py”,第4行,在
短语,complete_response=speech。speech_to_text('es_es')#选择语言
文件“C:/Python\pygsr\\ uuuuu init\ uuuuu.py”,第49行,在语音到文本中
音频=打开(文件上传,“rb”).read()
IOError:[Errno 2]没有这样的文件或目录:“audio.flac”
谁能告诉我我错过了什么。
或者请为python推荐任何好的语音到文本转换方法。

如果您错过了安装的将录制的wav转换为flac的sox工具,您可以在pygsr sources:system中看到(“sox%s-t wav-r 48000-t flac%s.flac”%(self.file,self.file))。确保sox为您工作,并且它可以创建flac文件。

您能详细说明一下吗?