- fix remaining audio results uploading
This commit is contained in:
parent
c186badb43
commit
ed3b91d8c1
|
|
@ -93,37 +93,28 @@ def upload_results():
|
|||
path_audio = t[1]
|
||||
|
||||
utils.log(f'Found {path_report.name} and {path_audio.name} files.')
|
||||
try:
|
||||
with open(path_report, 'rt') as f:
|
||||
report = json.loads(f.read())
|
||||
except:
|
||||
utils.log_error(f'Error when processing {path_report.name}')
|
||||
continue
|
||||
if path_report is not None and path_report.exists():
|
||||
try:
|
||||
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 = BACKEND.upload_report(report, cache=None)
|
||||
if success:
|
||||
utils.log(f'Report {upload_id} is uploaded ok.')
|
||||
upload_id, success = BACKEND.upload_report(report, cache=None)
|
||||
if success:
|
||||
utils.log(f'Report {upload_id} is uploaded ok.')
|
||||
|
||||
# Rename files to make sync audio filename with reported ones
|
||||
# path_report_fixed = CACHE.dir / f'{upload_id}.json'
|
||||
# path_report = path_report.rename(path_report_fixed)
|
||||
|
||||
# path_audio_fixed = CACHE.dir / f'{upload_id}.wav'
|
||||
# path_audio = path_audio.rename(path_audio_fixed)
|
||||
if path_audio.exists():
|
||||
utils.log(f'Uploading {path_audio.name} file...')
|
||||
# Upload recorded audio
|
||||
upload_result = BACKEND.upload_audio(upload_id, path_audio)
|
||||
if upload_result:
|
||||
utils.log(f' Recorded audio {upload_id}.wav is uploaded ok.')
|
||||
os.remove(path_audio)
|
||||
else:
|
||||
utils.log(f'No recorded audio file found, skipping audio upload.')
|
||||
os.remove(path_report)
|
||||
|
||||
else:
|
||||
utils.log(f'Failed to upload report {path_report.name}')
|
||||
break
|
||||
if path_audio is not None and path_audio.exists():
|
||||
utils.log(f'Uploading {path_audio.name} file...')
|
||||
# Upload recorded audio
|
||||
upload_result = BACKEND.upload_audio(upload_id, path_audio)
|
||||
if upload_result:
|
||||
utils.log(f' Recorded audio {upload_id}.wav is uploaded ok.')
|
||||
os.remove(path_audio)
|
||||
|
||||
|
||||
def run_analyze(file_test: str, file_reference: str, number: str) -> bool:
|
||||
global CALL_COUNTER
|
||||
|
|
|
|||
|
|
@ -80,11 +80,16 @@ class InfoCache:
|
|||
lst = os.listdir(self.dir)
|
||||
for n in lst:
|
||||
p = self.dir / n
|
||||
if self.is_valid_uuid(p.stem) and n.endswith('.json'):
|
||||
if self.is_valid_uuid(p.stem) and (n.endswith('.json') or n.endswith(".wav")):
|
||||
# Probe found
|
||||
p_json = p.with_suffix('.json')
|
||||
p_audio = p.with_suffix('.wav')
|
||||
if p_audio.exists():
|
||||
r.append((p, p.with_suffix('.wav')))
|
||||
if p_json.exists() and p_audio.exists():
|
||||
r.append((p_json, p_audio))
|
||||
elif p_json.exists():
|
||||
r.append((p_json, None))
|
||||
elif p_audio.exists():
|
||||
r.append((None, p_audio))
|
||||
|
||||
return r
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue