speech_recognition icon indicating copy to clipboard operation
speech_recognition copied to clipboard

FLAC conversion utility not available

Open Lvjinhong opened this issue 1 year ago • 3 comments

Steps to reproduce

  1. (How do you make the issue happen? Does it happen every time you try it?)
  2. (Make sure to go into as much detail as needed to reproduce the issue. Posting your code here can help us resolve the problem much faster!)
  3. (If there are any files, like audio recordings, don't forget to include them.)

Expected behaviour

(What did you expect to happen?)

it can run normally.

Actual behaviour

Although I have installed the necessary libraries for speech recognition, such as PyAudio, PocketSphinx, and FLAC, and can run the FLAC utility in the command line, my program still cannot find the path to FLAC and displays the error message "OSError: FLAC conversion utility not available". (What happened instead? How is it different from what you expected?)

Although I have installed the necessary libraries for speech recognition, such as PyAudio, PocketSphinx, and FLAC, and can run the FLAC utility in the command line, my program still cannot find the path to FLAC and displays the error message "OSError: FLAC conversion utility not available".

(If the library threw an exception, paste the full stack trace here).
Traceback (most recent call last):
  File "D:\1SoftWare\0Code\anaconda\envs\DataScience\lib\site-packages\IPython\core\interactiveshell.py", line 3433, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-8c38be5ab2f3>", line 1, in <module>
    runfile('D:\\0Data\\0AI_Python\\0project\\1NLP\\语音与文字\\main.py', wdir='D:\\0Data\\0AI_Python\\0project\\1NLP\\语音与文字')
  File "D:\1SoftWare\0Code\IDE\0Python\PyCharm 2022.2.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "D:\1SoftWare\0Code\IDE\0Python\PyCharm 2022.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:\0Data\0AI_Python\0project\1NLP\语音与文字\main.py", line 61, in <module>
    voice_input()
  File "D:\0Data\0AI_Python\0project\1NLP\语音与文字\main.py", line 56, in voice_input
    text = r.recognize_google(audio,language='zh-CN')
  File "D:\1SoftWare\0Code\anaconda\envs\DataScience\lib\site-packages\speech_recognition\__init__.py", line 879, in recognize_google
    flac_data = audio_data.get_flac_data(
  File "D:\1SoftWare\0Code\anaconda\envs\DataScience\lib\site-packages\speech_recognition\__init__.py", line 495, in get_flac_data
    flac_converter = get_flac_converter()
  File "D:\1SoftWare\0Code\anaconda\envs\DataScience\lib\site-packages\speech_recognition\__init__.py", line 1733, in get_flac_converter
    raise OSError("FLAC conversion utility not available - consider installing the FLAC command line application by running `apt-get install flac` or your operating system's equivalent")
OSError: FLAC conversion utility not available - consider installing the FLAC command line application by running `apt-get install flac` or your operating system's equivalent

System information

The issue was that, after the final debugging, I found that the problem was in the initialization file where the path to FLAC was searched for as "flac". However, for the Windows system, it should be "flac.exe". After changing the path to "flac.exe", the program can run normally.

(Delete all the statements that don't apply.)

My system is <INSERT SYSTEM HERE>. (For example, "Ubuntu 16.04 LTS x64", "Windows 10 x64", or "macOS Sierra".)

My Python version is <INSERT VERSION HERE>. (You can check this by running python -V.)

My Pip version is <INSERT VERSION HERE>. (You can check this by running pip -V.)

My SpeechRecognition library version is <INSERT VERSION HERE>. (You can check this by running python -c "import speech_recognition as sr;print(sr.__version__)".)

My PyAudio library version is <INSERT VERSION HERE> / I don't have PyAudio installed. (You can check this by running python -c "import pyaudio as p;print(p.__version__)".)

My microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())".)

My working microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_working_microphones())".)

I installed PocketSphinx from <INSERT SOURCE HERE>. (For example, from the Debian repositories, from Homebrew, or from the source code.)

Lvjinhong avatar Mar 08 '23 14:03 Lvjinhong