What is this error- “IOError: [Errno 2] No such fi

2020-04-14 08:26发布

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条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-04-14 09:11

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.

查看更多
登录 后发表回答