我正在编写一个程序,用于从内置麦克风获取语音输入,然后在屏幕上打印接收到的语音。我的程序如下:
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")
但我收到以下错误:
Traceback (most recent call last):
File "text.py", line 4, in <module>
with sr.Microphone() as source:
File "/home/ashish/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/ashish/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