基本上我想将语音转换为文本,所以我尝试使用 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:/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'
有人可以告诉我我错过了什么吗?
或者请推荐任何好的Python语音到文本转换方法。
您错过了安装的 sox 工具,该工具将录制的 wav 转换为 flac,您可以在 pygsr 源中看到: system("sox %s -t wav -r 48000 -t flac %s.flac" % (self.file, self.文件))。确保 sox 适合您并且它可以创建 flac 文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)