From d75e19665f47133e0e1c0ca4e6b54aa0d9498ef7 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Thu, 26 Feb 2026 21:32:29 -0500 Subject: [PATCH] Allow user to select audio input device at startup --- transcribe.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/transcribe.py b/transcribe.py index a7405e5..42cd622 100644 --- a/transcribe.py +++ b/transcribe.py @@ -62,18 +62,24 @@ def main(): model = MarianMTModel.from_pretrained(model_id).to(device) translation_engines[lang_name] = (model, tokenizer) - print("Loading Silero VAD model...") - vad_model = load_silero_vad() + print("\nAvailable Audio Devices:") + devices = sd.query_devices() + print(devices) - print("Models loaded.") + try: + device_input = input("\nSelect input device index (or press Enter for default): ") + device_index = int(device_input) if device_input.strip() else None + except ValueError: + print("Invalid input, using default device.") + device_index = None - print(f"\nStarting live transcription & multiple translations... (Press Ctrl+C to stop)") + print(f"\nStarting live transcription & multiple translations using device {device_index if device_index is not None else 'default'}... (Press Ctrl+C to stop)") audio_buffer = [] speech_started = False try: - with sd.InputStream(samplerate=SAMPLERATE, channels=CHANNELS, callback=callback, blocksize=BLOCK_SIZE): + with sd.InputStream(samplerate=SAMPLERATE, channels=CHANNELS, callback=callback, blocksize=BLOCK_SIZE, device=device_index): while True: while not audio_queue.empty(): data = audio_queue.get()