I am trying speech recognition with SpeechRecognition package in python and facing problem when trying to work with microphone.
I tested Microphone of my earphones , it is working fine and is being detected by my computer but my script is throwing error as if there is no mic connected.
When I run the following script after installing pyAudio
$python -m speech_recognition
I get following error:
Traceback (most recent call last):
File "/home/harshita/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/harshita/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/harshita/anaconda3/lib/python3.6/site-packages/speech_recognition/__main__.py", line 4, in <module>
m = sr.Microphone()
File "/home/harshita/anaconda3/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/harshita/anaconda3/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
And also:
import speech_recognition as sr
sr.Microphone.list_microphone_names()
output:
[ ]
Where is it that I am going wrong?
Also why is it showing 'OSError'?, I saw other related queries but all of them had it as IOError.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…