我正在尝试使用PyAudio和Ubuntu 16.04创建一个python程序来录制和循环音轨。我收到一条错误消息“未找到默认输入设备”。当我查询默认设备并尝试列出整个设备时,我得到相同的结果。但是,如果我在Ubuntu操作系统内检查所有设备都可以看到。这可能是什么问题?我发现其他一些线程说它可能是PortAudio库中的一个问题,但不知道从那里去哪里?
info = audio.get_host_api_info_by_index(0)
numDevices = info.get('deviceCount')
print ("Number of sounds devices: " + str(numDevices))
for i in range(0, numDevices):
if audio.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels') > 0:
print("Input Device ID "+ i + " - " + audio.get_dev-ce_info_by_host_api_index(0,i).get('name'))
输出: 声音设备数量:0
audio.get_default_output_device_info()
输出:
Traceback (most recent call last):
File "query_sound_devices.py", line 9, in <module>
audio.get_default_output_device_info()
File "/usr/local/lib/python3.5/dist-packages/pyaudio.py", line 962, in get_default_output_device_info
device_index = pa.get_default_output_device()
OSError: No Default Output Device Available
操作系统输出
root@osboxes:# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: I82801AAICH [Intel 82801AA-ICH], device 0: Intel ICH [Intel 82801AA-ICH]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: I82801AAICH [Intel 82801AA-ICH], device 1: Intel ICH - MIC ADC [Intel 82801AA-ICH - MIC ADC]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: C310 [Plantronics C310], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
答案 0 :(得分:1)
当您使用anaconda安装pyaudio和portaudio时,通常会出现此问题。
conda install nwani::portaudio nwani::pyaudio
conda remove pyaudio
conda remove portaudio
pip install pyaudio
他们中的任何一个都可以解决您的问题。