Last active 1729044033

check_audio_device_id.py Raw
1import pyaudio
2
3def list_audio_devices():
4 p = pyaudio.PyAudio()
5
6 print("Available audio devices:")
7 for i in range(p.get_device_count()):
8 device_info = p.get_device_info_by_index(i)
9 # 只打印输出设备
10 if device_info['maxOutputChannels'] > 0:
11 print(f"Device ID: {i}, Name: {device_info['name']}, Max Output Channels: {device_info['maxOutputChannels']}")
12
13 p.terminate()
14
15list_audio_devices()
16