我有一个带麦克风的Logitech摄像机。 我想从python访问麦克风的麦克风
我尝试列出pyaudio中的设备,但麦克风未显示在那里。
尝试过此代码
import pyaudio
p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
print ("Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name'))
Output1
Input Device id 0 - HDA Intel PCH: ALC255 Analog (hw:0,0)
Input Device id 2 - sysdefault
Input Device id 7 - pulse
Input Device id 9 - default
第二个代码:
import pyaudio
p = pyaudio.PyAudio()
for i in range(p.get_device_count()):
dev = p.get_device_info_by_index(i)
print((i,dev['name'],dev['maxInputChannels']))
Output2:
(0, 'HDA Intel PCH: ALC255 Analog (hw:0,0)', 2)
(1, 'HDA NVidia: HDMI 0 (hw:1,3)', 0)
(2, 'sysdefault', 128)
(3, 'front', 0)
(4, 'surround40', 0)
(5, 'surround51', 0)
(6, 'surround71', 0)
(7, 'pulse', 32)
(8, 'dmix', 0)
(9, 'default', 32)
未获取麦克风ID
注意-使用具有内置麦克风的Logitech摄像机
在linux(Ubuntu)上工作