本文介绍了这是什么错误-“IOError:[Errno 2] 没有这样的文件或目录:'audio.flac'",我正在尝试使用 google 语音识别 api for python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想将语音转换为文本,所以我尝试使用 google 语音识别 api for python.

Basically i want to convert speech to text, so I am trying to use the google voice recognition api for python.

这是我要运行的代码-

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

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

I've installed all the modules correctly, so probably nothing is wrong with the modules, i am getting the following error-

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文本转换方法.

Can somebody please tell me what am i missing.Or please suggest any good speech to text conversion method for python.

推荐答案

你错过了安装将录制的 wav 转换为 flac 的 sox 工具,你可以在 pygsr 源代码中看到:system("sox %s -t wav -r48000 -t flac %s.flac" % (self.file, self.file)).确保 sox 适合您并且它可以创建 flac 文件.

You miss the sox tool installed which converts recorded wav to flac, you can see in line in pygsr sources: system("sox %s -t wav -r 48000 -t flac %s.flac" % (self.file, self.file)). Make sure that sox works for you and it can create flac files.

这篇关于这是什么错误-“IOError:[Errno 2] 没有这样的文件或目录:'audio.flac'",我正在尝试使用 google 语音识别 api for python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-09 03:02