这是什么错误-“ IOError:[Errno 2]没有此类文件或目录:“ audio.flac””,我正在尝试将google语音识别api用于python [英] What is this error- "IOError: [Errno 2] No such file or directory: 'audio.flac' ", i am trying to use the google voice recognition api for python

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

问题描述

基本上我想将语音转换为文本,所以我试图将google语音识别api用于python。

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

这是我正在尝试的代码运行

This is the code which i'm trying to run-

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:/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的语音到文本转换方法的建议。

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

推荐答案

您会错过安装可进行转换的sox工具记录到flac的wav,您可以在pygsr来源中看到:system( sox%s -t wav -r 48000 -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用于python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆