Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/explorepy/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ class BleDisconnectionFailedError(Exception):
pass


class ImpedanceModeActiveError(Exception):
"""
Exception for ASR, raised when impedance is running
"""

def __init__(self, message="ASR can not run because impedance mode is active.\n"
"Please disable impedance and try again\n"):
super().__init__(message)


class ExplorePyDeprecationError(Exception):
def __init__(self, message="Explorepy support for legacy devices is deprecated.\n"
"Please install explorepy 3.2.1 from Github or use the following command from Anaconda "
Expand Down
2 changes: 1 addition & 1 deletion src/explorepy/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ def get_channel_mask(self):
return SettingsManager(self.device_name).get_adc_mask()

def is_asr_processor_available(self):
return self.stream_processor.asr_processor is not None and self.stream_processor.asr_processor.is_initialized
return self.stream_processor.is_asr_processor_available()

def calibrate_asr(self, length=-1.0):
if self.is_asr_processor_available():
Expand Down
6 changes: 6 additions & 0 deletions src/explorepy/stream_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import numpy as np

from explorepy._exceptions import ImpedanceModeActiveError
from explorepy.asr_processor import AsrProcessor
from explorepy.command import (
DeviceConfiguration,
Expand Down Expand Up @@ -619,3 +620,8 @@ def get_power_line_freq(self):
)

return match.cutoff_freq if match else None

def is_asr_processor_available(self):
if self.is_imp_running():
raise ImpedanceModeActiveError()
return self.asr_processor is not None and self.asr_processor.is_initialized
Loading