import pyaudio p = pyaudio.PyAudio() device_count = p.get_device_count() audio_device_list = [] for i in range(device_count): device = p.get_device_info_by_index(i) audio_device_list.append(device) print(audio_device_list) 通过以上代码可
p = pyaudio.PyAudio()
device_count = p.get_device_count()
audio_device_list = []
for i in range(device_count):
device = p.get_device_info_by_index(i)
audio_device_list.append(device)
print(audio_device_list)
通过以上代码可以获取当前设备的音频设备列表,但是旧版本有一个问题是每次请求pyaudio.PyAudio()是就会是正在播放的声音阻塞。
解决方案:
卸载旧版本pyaudio,使用0.2.12或者以上版本就可以了
pyaudio地址:
https://pypi.org/project/PyAudio/#history