From 9504a2295cfd133447277f9968c13ba15a9620a7 Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Wed, 23 Aug 2023 10:39:40 +0300 Subject: [PATCH] - +1 fix --- src/agent_gsm.py | 10 ++++++++-- src/bt_phone.py | 4 ++-- src/utils.py | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/agent_gsm.py b/src/agent_gsm.py index 47dc37f..23e0917 100644 --- a/src/agent_gsm.py +++ b/src/agent_gsm.py @@ -67,10 +67,11 @@ FORCE_RUN = False EXIT_OK = 0 EXIT_ERROR = 1 - # Use silence eraser or not (speech detector is used in this case) USE_SILENCE_ERASER = True +LOG_FILEPATH = None + def remove_oldest_log_audio(): list_of_files = os.listdir(LOG_AUDIO_DIR) if len(list_of_files) > 20: @@ -256,6 +257,7 @@ def make_call(target: str): # os.remove(record_file) # Add prefix and suffix silence for reference to give a chance to record all the file + utils.log(f'Preparing reference file...') reference_filename = Path('/dev/shm/reference_built.wav') if reference_filename.exists(): os.remove(reference_filename) @@ -263,10 +265,13 @@ def make_call(target: str): # Find duration of prepared reference file reference_length = int(utils.get_wav_length(reference_filename)) + utils.log(f' Done.') # Compose a command + utils.close_log_file() cmd = f'/usr/bin/python3 {DIR_THIS}/bt_call_controller.py --play-file {reference_filename} --record-file {record_file} --timelimit {reference_length} --target {target}' retcode = os.system(cmd) + utils.open_log_file(LOG_FILEPATH, 'at') if retcode != 0: utils.log_error(f'BT caller script exited with non-zero code {retcode}, skipping analysis.') else: @@ -499,7 +504,8 @@ if 'bluetooth_mac' in config['audio']: utils.verbose_logging = config['log']['verbose'] if config['log']['path']: - utils.open_log_file(config['log']['path'], 'at') + LOG_FILEPATH = config['log']['path'] + utils.open_log_file(LOG_FILEPATH, 'at') # Use native ALSA utilities on RPi if utils.is_raspberrypi(): diff --git a/src/bt_phone.py b/src/bt_phone.py index e5d5c9c..052be67 100644 --- a/src/bt_phone.py +++ b/src/bt_phone.py @@ -96,11 +96,11 @@ class Phone(Observable): def __init__(self): super(Phone,self).__init__() - + utils.log('Ataching to DBus...') # Attach to DBus dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - utils.log('Phone set up') + utils.log('Going to setup phone...') self.bus = dbus.SystemBus() # Get ofono manager diff --git a/src/utils.py b/src/utils.py index 9499591..2606d2f 100644 --- a/src/utils.py +++ b/src/utils.py @@ -1,4 +1,5 @@ #!/usr/bin/python + import typing import datetime import traceback