- support offline mode
This commit is contained in:
parent
9d2ba8c998
commit
937bafb493
|
|
@ -29,9 +29,9 @@ RECORD_FILE = "/dev/shm/qualtest_recorded.wav"
|
||||||
BackendServer : utils_qualtest.QualtestBackend = None
|
BackendServer : utils_qualtest.QualtestBackend = None
|
||||||
|
|
||||||
# Reference audio to play
|
# Reference audio to play
|
||||||
REFERENCE_AUDIO = "/dev/shm/reference.wav"
|
REFERENCE_AUDIO = "/dev/shm/reference_original.wav"
|
||||||
|
|
||||||
# Loaded refernce audio (from backend)
|
# Loaded reference audio (from backend)
|
||||||
LOADED_AUDIO = Path("/dev/shm/loaded_audio.wav")
|
LOADED_AUDIO = Path("/dev/shm/loaded_audio.wav")
|
||||||
|
|
||||||
# Script to exec after mobile call answering
|
# Script to exec after mobile call answering
|
||||||
|
|
@ -105,6 +105,7 @@ def detect_reference_signal(file_reference: Path) -> SignalBoundaries:
|
||||||
|
|
||||||
|
|
||||||
def upload_results():
|
def upload_results():
|
||||||
|
utils.log(f'Uploading remaining results...')
|
||||||
probe_list = CACHE.get_probe_list()
|
probe_list = CACHE.get_probe_list()
|
||||||
for t in probe_list:
|
for t in probe_list:
|
||||||
# Path to .json report
|
# Path to .json report
|
||||||
|
|
@ -113,8 +114,12 @@ def upload_results():
|
||||||
# Path to audio
|
# Path to audio
|
||||||
path_audio = t[1]
|
path_audio = t[1]
|
||||||
|
|
||||||
with open(path_report, 'rt') as f:
|
try:
|
||||||
report = json.loads(f.read())
|
with open(path_report, 'rt') as f:
|
||||||
|
report = json.loads(f.read())
|
||||||
|
except:
|
||||||
|
utils.log_error(f'Error when processing {path_report.name}')
|
||||||
|
continue
|
||||||
|
|
||||||
upload_id, success = BackendServer.upload_report(report, cache=None)
|
upload_id, success = BackendServer.upload_report(report, cache=None)
|
||||||
if success:
|
if success:
|
||||||
|
|
@ -136,6 +141,7 @@ def upload_results():
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
utils.log(f'Failed to upload report {path_report.name}')
|
||||||
break
|
break
|
||||||
|
|
||||||
def run_analyze(file_test: str, file_reference: str, number: str) -> bool:
|
def run_analyze(file_test: str, file_reference: str, number: str) -> bool:
|
||||||
|
|
@ -249,8 +255,10 @@ def make_call(target: str):
|
||||||
# os.remove(record_file)
|
# os.remove(record_file)
|
||||||
|
|
||||||
# Add prefix and suffix silence for reference to give a chance to record all the file
|
# Add prefix and suffix silence for reference to give a chance to record all the file
|
||||||
reference_filename = '/dev/shm/prepared_reference.wav'
|
reference_filename = Path('/dev/shm/reference_built.wav')
|
||||||
utils.prepare_reference_file(fname=REFERENCE_AUDIO, silence_prefix_length=10.0, silence_suffix_length=5.0, output_fname=reference_filename)
|
if reference_filename.exists():
|
||||||
|
os.remove(reference_filename)
|
||||||
|
utils.prepare_reference_file(fname=str(REFERENCE_AUDIO), silence_prefix_length=10.0, silence_suffix_length=5.0, output_fname=str(reference_filename))
|
||||||
|
|
||||||
# Find duration of prepared reference file
|
# Find duration of prepared reference file
|
||||||
reference_length = int(utils.get_wav_length(reference_filename))
|
reference_length = int(utils.get_wav_length(reference_filename))
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class InfoCache:
|
||||||
# Probe found
|
# Probe found
|
||||||
p_audio = p.with_suffix('.wav')
|
p_audio = p.with_suffix('.wav')
|
||||||
if p_audio.exists():
|
if p_audio.exists():
|
||||||
r.append(p, p.with_suffix('.wav'))
|
r.append((p, p.with_suffix('.wav')))
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ class CallState(enum.Enum):
|
||||||
# Monitor logcat output and tell about events
|
# Monitor logcat output and tell about events
|
||||||
# on_start is lambda with 3 parameters (file_test, file_reference, phone_number)
|
# on_start is lambda with 3 parameters (file_test, file_reference, phone_number)
|
||||||
# on_finish is lambda with 3 parameters (file_test, file_reference, phone_number)
|
# on_finish is lambda with 3 parameters (file_test, file_reference, phone_number)
|
||||||
PREPARED_REFERENCE_AUDIO = '/dev/shm/reference_prepared.wav'
|
PREPARED_REFERENCE_AUDIO = '/dev/shm/built_reference.wav'
|
||||||
|
|
||||||
def gsm_monitor(file_to_play: str, file_to_record: str, on_start, on_finish, on_error):
|
def gsm_monitor(file_to_play: str, file_to_record: str, on_start, on_finish, on_error):
|
||||||
global PREPARED_REFERENCE_AUDIO, STOP_FLAG, USE_ALSA_AUDIO, AUDIO_DEV_RECORD, AUDIO_DEV_PLAY
|
global PREPARED_REFERENCE_AUDIO, STOP_FLAG, USE_ALSA_AUDIO, AUDIO_DEV_RECORD, AUDIO_DEV_PLAY
|
||||||
|
|
|
||||||
|
|
@ -66,12 +66,12 @@ class QualtestBackend:
|
||||||
self.__phone = self.load_phone(cache)
|
self.__phone = self.load_phone(cache)
|
||||||
|
|
||||||
|
|
||||||
def upload_report(self, report, cache: InfoCache) -> (str, bool):
|
def upload_report(self, report: dict, cache: InfoCache) -> (str, bool):
|
||||||
# UUID string as result
|
# UUID string as result
|
||||||
result = (None, False)
|
result = (None, False)
|
||||||
|
|
||||||
# Log about upload attempt
|
# Log about upload attempt
|
||||||
utils.log_verbose(f"Uploading to {self.address} report: {json.dumps(report, indent=4)}")
|
utils.log_verbose(f'Uploading to {self.address} report with audio duration: {report["duration"]}s, AQuA MOS: {round(report["mos_aqua"], 3)}')
|
||||||
url = utils.join_host_and_path(self.address, "/probes/")
|
url = utils.join_host_and_path(self.address, "/probes/")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -82,7 +82,7 @@ class QualtestBackend:
|
||||||
|
|
||||||
result = (r.content.decode().strip(), True)
|
result = (r.content.decode().strip(), True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
utils.log_error(f"Upload report to {self.address} finished with error.", err=e)
|
utils.log_error(f'Upload report to {self.address} finished with error: {str(e)}')
|
||||||
# Backup probe result
|
# Backup probe result
|
||||||
if cache is not None:
|
if cache is not None:
|
||||||
probe_id = cache.add_report(report)
|
probe_id = cache.add_report(report)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue