Allow user to select audio input device at startup
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user