diff --git a/src/app.py b/src/app.py index 4dd61d4..7bcf103 100644 --- a/src/app.py +++ b/src/app.py @@ -97,7 +97,6 @@ def main() -> None: client.loop_forever() # This blocks except KeyboardInterrupt: logging.info("SIGINT recieved! Stopping...") - pass client.disconnect() loopingtimer.stop() diff --git a/src/preprocessor/soundpreprocessor.py b/src/preprocessor/soundpreprocessor.py index 87949ee..a4324db 100644 --- a/src/preprocessor/soundpreprocessor.py +++ b/src/preprocessor/soundpreprocessor.py @@ -80,8 +80,9 @@ class SoundPreProcessor(AbcPreProcessor): logging.info("The loaded model contains the following classes: " + ", ".join(self._classes)) if target_class_name not in self._classes: - raise Exception( - f"The specified target class {target_class_name} is not in the possible classes (Wrong model info?)") + raise ValueError( + f"The specified target class {target_class_name} is not in the possible classes (Wrong model info?)" + ) self._target_id = self._classes.index(target_class_name) @@ -97,10 +98,10 @@ class SoundPreProcessor(AbcPreProcessor): signal = audioBasicIO.stereo_to_mono(signal) if sampling_rate == 0: - raise Exception("Could not read the file properly: Sampling rate zero") + raise AssertionError("Could not read the file properly: Sampling rate zero") if signal.shape[0] / float(sampling_rate) <= self._mid_window: - raise Exception("Could not read the file properly: Signal shape is not good") + raise AssertionError("Could not read the file properly: Signal shape is not good") # feature extraction: mid_features, s, _ = \ diff --git a/src/utils/loopingtimer.py b/src/utils/loopingtimer.py index 3f8add3..efaeef9 100644 --- a/src/utils/loopingtimer.py +++ b/src/utils/loopingtimer.py @@ -15,7 +15,7 @@ class LoopingTimer: """ Looping timer. Executes a function and repeates it in the given interval. """ - def __init__(self, interval, function, tick_args=[], tick_kwargs={}): + def __init__(self, interval, function, tick_args=None, tick_kwargs=None): """ Initialize class :param interval: @@ -26,8 +26,8 @@ class LoopingTimer: self._timer = None self.interval = interval self.function = function - self._tick_args = tick_args - self._tick_kwargs = tick_kwargs + self._tick_args = tick_args or [] + self._tick_kwargs = tick_kwargs or {} self.is_running = False self.start()