From 8afaf66ea78cf580e6c8bf4a68473b483bc74b49 Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Mon, 3 Apr 2023 22:04:38 -0400 Subject: [PATCH] Create try/except statement around reading the audio data from the recordings. See the issue linked in the PR. By clearing the text in analyzing_now, my system moves past the error-causing file and continues processing. --- scripts/server.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/server.py b/scripts/server.py index 7e478df..46a069a 100755 --- a/scripts/server.py +++ b/scripts/server.py @@ -395,8 +395,16 @@ def handle_client(conn, addr): birdweather_id = args.birdweather_id - # Read audio data - audioData = readAudioData(args.i, args.overlap) + # Read audio data & handle errors + try: + audioData = readAudioData(args.i, args.overlap) + + except (NameError, TypeError) as e: + print(f"Error with the following info: {e}") + open('~/BirdNET-Pi/analyzing_now.txt', 'w').close() + + finally: + pass # Get Date/Time from filename in case Pi gets behind # now = datetime.now() @@ -560,7 +568,7 @@ def handle_client(conn, addr): post_algorithm = "\"algorithm\": " + "\"2p2\"" + "," else: post_algorithm = "\"algorithm\": " + "\"alpha\"" + "," - + post_confidence = "\"confidence\": " + str(entry[1]) post_end = " }"