From 65cab5fa3ca98b223f6bed5d4f33fbd547f7c76a Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Tue, 29 Nov 2022 08:45:14 +0100 Subject: [PATCH] fixed crash if audio volume has wrong type --- tnc/modem.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tnc/modem.py b/tnc/modem.py index 0a008299..2b272b20 100644 --- a/tnc/modem.py +++ b/tnc/modem.py @@ -1014,6 +1014,13 @@ def set_audio_volume(datalist, volume: float) -> np.int16: :return: Scaled audio samples :rtype: np.int16 """ + # make sure we have float as data type to avoid crash + try: + volume = float(volume) + except Exception as e: + print(f"[MDM] changing audio volume failed with error: {e}") + volume = 100.0 + # Clip volume provided to acceptable values volume = np.clip(volume, 0, 200) # limit to max value of 255 # Scale samples by the ratio of volume / 100.0