![在 Ubuntu 18.04 中设置默认输入设备](https://linux22.com/image/906687/%E5%9C%A8%20Ubuntu%2018.04%20%E4%B8%AD%E8%AE%BE%E7%BD%AE%E9%BB%98%E8%AE%A4%E8%BE%93%E5%85%A5%E8%AE%BE%E5%A4%87.png)
我正在编写一个程序,用于从内置麦克风获取语音输入,然后在屏幕上打印接收到的语音。我的程序如下:
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