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

≡放荡痞女 提交于 2019-12-02 03:17:34

问题


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'

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


回答1:


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.



来源:https://stackoverflow.com/questions/24436855/what-is-this-error-ioerror-errno-2-no-such-file-or-directory-audio-flac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!