SpeechRecognition producing OSError: No Default Input Device Available

我只是一个虾纸丫 提交于 2021-01-04 07:17:02

问题


This:

import speech_recognition as sr

r = sr.Recognizer()
with sr.Microphone() as source:
    print("Speak Anything :")
    audio = r.listen(source)
    try:
        text = r.recognize_google(audio)
        print("You said : {}".format(text))
    except:
        print("Sorry could not recognize what you said")

Producing this:

Traceback (most recent call last):
  File "magic.py", line 5, in <module>
    with sr.Microphone() as source:
  File "/home/myPorfile/anaconda3/envs/customEnv/lib/python3.6/site-packages/speech_recognition/__init__.py", line 86, in __init__
    device_info = audio.get_device_info_by_index(device_index) if device_index is not None else audio.get_default_input_device_info()
  File "/home/myPorfile/anaconda3/envs/customEnv/lib/python3.6/site-packages/pyaudio.py", line 949, in get_default_input_device_info
    device_index = pa.get_default_input_device()
OSError: No Default Input Device Available

Apparently Pyaudio is not detecting my Earphone nor my computer's mic.

sr.Microphone.list_microphone_names() verifying that by returning an empty list [].

I also tried installing Pyaudio and portaudio.

Using: Ubuntu 18.04.2 LTS / python 3.6

来源:https://stackoverflow.com/questions/56096427/speechrecognition-producing-oserror-no-default-input-device-available

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