问题
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