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.
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