feat: add PortAudio device enumeration utility
- Created script to list all available audio input/output devices with their capabilities - Displays host APIs, channel counts, sample rates, and device names for configuration - Includes helpful hints for selecting appropriate capture and playback devices
This commit is contained in:
27
list_portaudio_devices.py
Normal file
27
list_portaudio_devices.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
try:
|
||||
import sounddevice as sd
|
||||
except Exception as e:
|
||||
sys.stderr.write("sounddevice is not installed or failed to import. Install with: pip install sounddevice\n")
|
||||
raise
|
||||
|
||||
ha = sd.query_hostapis()
|
||||
print("Host APIs:")
|
||||
for i, h in enumerate(ha):
|
||||
print(f"{i}: {h.get('name')}")
|
||||
|
||||
print("\nDevices:")
|
||||
for i, d in enumerate(sd.query_devices()):
|
||||
api_idx = d.get('hostapi')
|
||||
api = ha[api_idx].get('name') if isinstance(api_idx, int) and 0 <= api_idx < len(ha) else '?'
|
||||
name = d.get('name')
|
||||
mi = int(d.get('max_input_channels') or 0)
|
||||
mo = int(d.get('max_output_channels') or 0)
|
||||
sr = int(d.get('default_samplerate') or 0)
|
||||
print(f"{i:2d} | in={mi:<2d} out={mo:<2d} sr={sr:<6d} api={api} name={name}")
|
||||
|
||||
print("\nHints:")
|
||||
print("- Pick an INPUT index with in>0 that matches your capture device name (e.g., 'USB Audio Device').")
|
||||
print("- Pick an OUTPUT index with out>0 that matches your playback device name (e.g., 'USB Audio').")
|
||||
print("- We will use mono (channels=1). If mono fails, we can fall back to 2 channels.")
|
||||
Reference in New Issue
Block a user