From 7435d7ef09d16cdf6af6a9c61e29dd85ecf6ca0a Mon Sep 17 00:00:00 2001 From: Mason10198 <31994327+Mason10198@users.noreply.github.com> Date: Mon, 31 Jul 2023 17:10:04 -0500 Subject: [PATCH] v0.4.2 update --- SkywarnPlus.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/SkywarnPlus.py b/SkywarnPlus.py index ccc07e8..c420603 100644 --- a/SkywarnPlus.py +++ b/SkywarnPlus.py @@ -914,6 +914,7 @@ def build_tailmessage(alerts): ) ) + added_counties = set() for ( alert, counties, @@ -965,7 +966,11 @@ def build_tailmessage(alerts): else: word_space = AudioSegment.silent(duration=400) county_code = county["county_code"] - if COUNTY_WAVS and county_code in COUNTY_CODES: + if ( + COUNTY_WAVS + and county_code in COUNTY_CODES + and county_code not in added_counties + ): index = COUNTY_CODES.index(county_code) county_name_file = COUNTY_WAVS[index] LOGGER.debug( @@ -974,18 +979,25 @@ def build_tailmessage(alerts): county_name_file, alert, ) - combined_sound += word_space + AudioSegment.from_wav( - os.path.join(SOUNDS_PATH, county_name_file) - ) - # if this is the last county name, add 600ms of silence after the county name - if counties.index(county) == len(counties) - 1: - combined_sound += AudioSegment.silent(duration=600) + try: + combined_sound += word_space + AudioSegment.from_wav( + os.path.join(SOUNDS_PATH, county_name_file) + ) + # if this is the last county name, add 600ms of silence after the county name + if counties.index(county) == len(counties) - 1: + combined_sound += AudioSegment.silent(duration=600) + added_counties.add(county_code) + except FileNotFoundError: + LOGGER.error( + "buildTailMessage: Audio file not found: %s", + os.path.join(SOUNDS_PATH, county_name_file), + ) except ValueError: LOGGER.error("Alert not found: %s", alert) except FileNotFoundError: LOGGER.error( - "Audio file not found: %s/ALERTS/SWP_%s.wav", + "buildTailMessage: Audio file not found: %s/ALERTS/SWP_%s.wav", SOUNDS_PATH, ALERT_INDEXES[index], )