From c79f3cdfbcea9930066191d2f1e7459579be0342 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 12 Nov 2025 16:18:26 -0800 Subject: [PATCH] Update icad_tone.py --- etc/icad_tone.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/etc/icad_tone.py b/etc/icad_tone.py index c6f266a..9beedf5 100644 --- a/etc/icad_tone.py +++ b/etc/icad_tone.py @@ -164,9 +164,9 @@ def main(): print(f"Error processing HTTP stream: {e}", file=sys.stderr) sys.exit(4) elif AUDIO_SOURCE == "soundcard": - # print("Available audio devices:") - # for i, dev in enumerate(sd.query_devices()): - # print(f"{i}: {dev['name']} ({dev['max_input_channels']} in, {dev['max_output_channels']} out)") + print("Available audio devices:") + for i, dev in enumerate(sd.query_devices()): + print(f"{i}: {dev['name']} ({dev['max_input_channels']} in, {dev['max_output_channels']} out)") print("Listening to audio device:") buffer = np.array([], dtype=np.float32) # Set a larger chunk size for detection, e.g. 8192 @@ -205,10 +205,11 @@ def main(): device=INPUT_DEVICE ): print("Press Ctrl+C to stop.") - import signal - signal.pause() # Wait for Ctrl+C, keeps CPU usage minimal - except KeyboardInterrupt: - print("Stopped by user.") + try: + while True: + time.sleep(0.5) # Keeps CPU usage low + except KeyboardInterrupt: + print("Stopped by user.") except Exception as e: print(f"Error accessing soundcard: {e}", file=sys.stderr) sys.exit(5)