diff --git a/src/agent_gsm.py b/src/agent_gsm.py index d6da42f..a7f95d3 100644 --- a/src/agent_gsm.py +++ b/src/agent_gsm.py @@ -46,6 +46,9 @@ CACHE = utils_cache.InfoCache(None) # Backend instance BACKEND : utils_qualtest.QualtestBackend = None +# ANalyzer binaries found or not ? +VOICE_QUALITY_AVAILABLE = False + def remove_oldest_log_audio(): list_of_files = os.listdir(LOG_AUDIO_DIR) if len(list_of_files) > 20: @@ -126,7 +129,10 @@ def run_analyze(file_test: str, file_reference: str, number: str) -> bool: global CALL_COUNTER result = False - + if not VOICE_QUALITY_AVAILABLE: + utils.log('Voice quality analyzers are not available, skipping analysis.') + return + if file_test.exists(): # Wait 5 seconds to give a chance to flush recorded file time.sleep(5.0) @@ -491,7 +497,7 @@ if __name__ == '__main__': # Update path to pvqa/aqua-wb - utils_sevana.find_binaries(DIR_PROJECT / 'bin') + VOICE_QUALITY_AVAILABLE = utils_sevana.find_binaries(DIR_PROJECT / 'bin') # Load latest licenses & configs - this requires utils_sevana.find_binaries() to be called before # utils_sevana.load_config_and_licenses(config['backend']) diff --git a/src/bt_controller.py b/src/bt_controller.py index a13176a..fe7aca0 100644 --- a/src/bt_controller.py +++ b/src/bt_controller.py @@ -14,7 +14,7 @@ class Bluetoothctl: def __init__(self): out = subprocess.check_output("/usr/sbin/rfkill unblock bluetooth", shell = True) # print("Bluetoothctl") - self.child = pexpect.spawn("/usr/bin/bluetoothctl", echo = False) + self.child = pexpect.spawn("/usr/bin/sudo /usr/bin/bluetoothctl", echo = False) def get_output(self, command, pause = 0): """Run a command in bluetoothctl prompt, return output as a list of lines.""" diff --git a/src/utils_sevana.py b/src/utils_sevana.py index fbbde21..23ffa9d 100644 --- a/src/utils_sevana.py +++ b/src/utils_sevana.py @@ -81,7 +81,7 @@ def load_config_and_licenses(server: str): except Exception as e: utils.log_error(f'Failed to fetch new licenses and config. Skipping it.') -def find_binaries(bin_directory: Path, license_server: str = None): +def find_binaries(bin_directory: Path, license_server: str = None) -> bool: # Update path to pvqa/aqua-wb global PVQA_CFG_PATH, PVQA_LIC_PATH, AQUA_LIC_PATH, PVQA_PATH, AQUA_PATH, PVQA_CMD, AQUA_CMD, SILER_PATH, SPEECH_DETECTOR_PATH @@ -109,16 +109,16 @@ def find_binaries(bin_directory: Path, license_server: str = None): PVQA_CFG_PATH = Path(utils.get_script_path()) / 'pvqa.cfg' if not PVQA_CFG_PATH.exists(): - utils.log_error(f'Failed to find pvqa config. Exiting.') - sys.exit(1) + utils.log_error(f'Failed to find pvqa config.') + return False if not AQUA_PATH.exists(): - utils.log_error(f'Failed to find aqua-wb binary. Exiting.') - sys.exit(1) + utils.log_error(f'Failed to find aqua-wb binary.') + return False if not SILER_PATH.exists(): - utils.log_error(f'Failed to find silence_eraser binary. Exiting.') - sys.exit(1) + utils.log_error(f'Failed to find silence_eraser binary..') + return False if license_server is not None: AQUA_LIC_PATH = '"license://' + license_server + '"' @@ -128,16 +128,17 @@ def find_binaries(bin_directory: Path, license_server: str = None): if not PVQA_LIC_PATH.exists(): PVQA_LIC_PATH = Path(utils.get_script_path()) / 'pvqa.lic' if not PVQA_LIC_PATH.exists(): - utils.log_error(f'Failed to find pvqa license. Exiting.') - sys.exit(1) + utils.log_error(f'Failed to find pvqa license.') + return False if not AQUA_LIC_PATH.exists(): AQUA_LIC_PATH = Path(utils.get_script_path()) / 'aqua-wb.lic' if not AQUA_LIC_PATH.exists(): - utils.log_error(f'Failed to find AQuA license. Exiting.') - sys.exit(1) + utils.log_error(f'Failed to find AQuA license.') + return False utils.log(f' Found all analyzers.') + return True def speech_detector(test_path: str):