From 5f2474d7ee6f407fbc7adb8eea22b6ead3854f2e Mon Sep 17 00:00:00 2001 From: Sonja Stefani Date: Fri, 17 Apr 2026 12:30:33 +0200 Subject: [PATCH 1/2] Added exception handling when calibration succeeds but state setting fails --- src/explorepy/asr_processor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/explorepy/asr_processor.py b/src/explorepy/asr_processor.py index 7bc905e3..0da7f58b 100644 --- a/src/explorepy/asr_processor.py +++ b/src/explorepy/asr_processor.py @@ -281,4 +281,9 @@ def set_state_from_calibration_data(self, calib_data): if cleaned is None: self.calibration_data_available = False return - self._state = asr_calibrate(cleaned, self.sr, cutoff=self._cutoff) + try: + self._state = asr_calibrate(cleaned, self.sr, cutoff=self._cutoff) + except np.linalg.LinAlgError as e: + self.calibration_data_available = False + self.lifecycle_state = State.CALIBRATION_ERROR + logger.error(f"Could not calibrate ASR: {e}") From 9aa668fd8875d9696d439ce9dce3a87742a2afb5 Mon Sep 17 00:00:00 2001 From: Sonja Stefani Date: Fri, 17 Apr 2026 17:21:11 +0200 Subject: [PATCH 2/2] Return when no calib data on clean, set lifecycle state after critical calls --- src/explorepy/asr_processor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/explorepy/asr_processor.py b/src/explorepy/asr_processor.py index 0da7f58b..100e56c1 100644 --- a/src/explorepy/asr_processor.py +++ b/src/explorepy/asr_processor.py @@ -200,6 +200,7 @@ def on_unclean_data_received(self, packet): self.last_clean_at = time.time() if not self.calibration_data_available: logger.warning("Attempting to clean data with no calibration available - returning...") + return new_data = np.array(packet.get_data()[1]) new_ts = np.array(packet.get_data()[0]) self.to_clean[:, :new_data.shape[1]] = new_data @@ -277,12 +278,13 @@ def stop_calibration(self): def set_state_from_calibration_data(self, calib_data): self.lifecycle_state = State.CLEANING cleaned, state = clean_calib_data(calib_data, self.sr) - self.lifecycle_state = state if cleaned is None: self.calibration_data_available = False + self.lifecycle_state = state return try: self._state = asr_calibrate(cleaned, self.sr, cutoff=self._cutoff) + self.lifecycle_state = state except np.linalg.LinAlgError as e: self.calibration_data_available = False self.lifecycle_state = State.CALIBRATION_ERROR