diff options
| author | yum <yum.food.vr@gmail.com> | 2025-07-23 22:39:45 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-07-23 22:39:45 -0700 |
| commit | f6b93a20d754579008076e85f5c0a97e1bcbc258 (patch) | |
| tree | 7288699d6f22e76c4f30636a37e94265b3ef7708 /app/list_microphones.py | |
| parent | f3782c200c9a2ec2b77708da67b4127a38465ad1 (diff) | |
| parent | 043a447133695bfd2285a534b941db972873a692 (diff) | |
Import FastTextPager repo
Diffstat (limited to 'app/list_microphones.py')
| -rw-r--r-- | app/list_microphones.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/list_microphones.py b/app/list_microphones.py new file mode 100644 index 0000000..a6b1f36 --- /dev/null +++ b/app/list_microphones.py @@ -0,0 +1,24 @@ +import pyaudio +import json +import sys + +try: + p = pyaudio.PyAudio() + info = p.get_host_api_info_by_index(0) + numdevices = info.get('deviceCount') + + microphones = [] + for i in range(0, numdevices): + device_info = p.get_device_info_by_host_api_device_index(0, i) + if device_info.get('maxInputChannels') > 0: + microphones.append({ + 'index': i, + 'name': device_info.get('name'), + 'defaultSampleRate': device_info.get('defaultSampleRate') + }) + + print(json.dumps(microphones)) + p.terminate() +except Exception as e: + print(json.dumps({'error': str(e)}), file=sys.stderr) + sys.exit(1)
\ No newline at end of file |
