- prefix & suffix reference audio with silence
This commit is contained in:
parent
f8f2aaa33b
commit
dc5a22bc0a
|
|
@ -51,6 +51,10 @@ class AgentConfig:
|
|||
# Task limit per single run
|
||||
TaskLimit: int = 10000000
|
||||
|
||||
# How to modify reference audio before play
|
||||
SilenceSuffix: int = 0
|
||||
SilencePrefix: int = 0
|
||||
|
||||
# Task name (used for answering only)
|
||||
TaskName: str = None
|
||||
|
||||
|
|
@ -88,9 +92,14 @@ class AgentConfig:
|
|||
if config['speech_detector']:
|
||||
self.UseSilenceEraser = False
|
||||
|
||||
if 'bluetooth_mac' in config['audio']:
|
||||
self.BT_MAC = config['audio']['bluetooth_mac']
|
||||
|
||||
if 'audio' in config:
|
||||
audio = config['audio']
|
||||
if 'bluetooth_mac' in audio:
|
||||
self.BT_MAC = audio['bluetooth_mac']
|
||||
if 'silence_suffix' in audio:
|
||||
self.SilenceSuffix = audio['silence_suffix']
|
||||
if 'silence_prefix' in audio:
|
||||
self.SilencePrefix = audio['silence_prefix']
|
||||
|
||||
# Logging settings
|
||||
if 'log' in config:
|
||||
|
|
|
|||
|
|
@ -239,17 +239,22 @@ def make_call(target: str):
|
|||
if CONFIG.PreparedReferenceAudio.exists():
|
||||
os.remove(CONFIG.PreparedReferenceAudio)
|
||||
utils.prepare_reference_file(fname=str(CONFIG.ReferenceAudio),
|
||||
silence_prefix_length=10.0, silence_suffix_length=5.0,
|
||||
silence_prefix_length=CONFIG.SilencePrefix,
|
||||
silence_suffix_length=CONFIG.SilenceSuffix,
|
||||
output_fname=str(CONFIG.PreparedReferenceAudio))
|
||||
|
||||
# Find duration of prepared reference file
|
||||
reference_length = round(utils.get_wav_length(CONFIG.PreparedReferenceAudio), 3)
|
||||
utils.log(f' Done. Length of prepared reference audio file: {reference_length}s')
|
||||
ref_time_length = round(utils.get_wav_length(CONFIG.PreparedReferenceAudio), 3)
|
||||
utils.log(f' Done. Length of prepared reference audio file: {ref_time_length}s')
|
||||
|
||||
# Compose a command
|
||||
# utils.close_log_file()
|
||||
try:
|
||||
bt_call_controller.run(play_file=CONFIG.PreparedReferenceAudio, record_file=CONFIG.RecordFile, timelimit_seconds=reference_length, target=target)
|
||||
bt_call_controller.run(play_file=CONFIG.PreparedReferenceAudio,
|
||||
record_file=CONFIG.RecordFile,
|
||||
timelimit_seconds=ref_time_length,
|
||||
target=target)
|
||||
|
||||
run_analyze(CONFIG.RecordFile, CONFIG.ReferenceAudio, target)
|
||||
except Exception as e:
|
||||
utils.log_error(f'BT I/O failed finally. Error: {str(e)}')
|
||||
|
|
@ -258,8 +263,14 @@ def make_call(target: str):
|
|||
def perform_answerer():
|
||||
global CALL_LIMIT
|
||||
|
||||
# Prepare answering file - this must be prepended with few seconds of silence which can be eatean by call setup procedure
|
||||
utils.prepare_reference_file(fname=str(CONFIG.ReferenceAudio),
|
||||
silence_prefix_length=CONFIG.SilencePrefix,
|
||||
silence_suffix_length=CONFIG.SilenceSuffix,
|
||||
output_fname=str(CONFIG.PreparedReferenceAudio))
|
||||
|
||||
# Get reference audio duration in seconds
|
||||
ref_time_length = round(utils.get_wav_length(CONFIG.ReferenceAudio), 3)
|
||||
ref_time_length = round(utils.get_wav_length(CONFIG.PreparedReferenceAudio), 3)
|
||||
|
||||
# Setup analyzer script
|
||||
# Run answering script
|
||||
|
|
@ -270,7 +281,7 @@ def perform_answerer():
|
|||
os.remove(CONFIG.RecordFile)
|
||||
|
||||
try:
|
||||
bt_call_controller.run(play_file=CONFIG.ReferenceAudio,
|
||||
bt_call_controller.run(play_file=CONFIG.PreparedReferenceAudio,
|
||||
record_file=CONFIG.RecordFile,
|
||||
timelimit_seconds=int(ref_time_length),
|
||||
target=None)
|
||||
|
|
@ -284,6 +295,7 @@ def perform_answerer():
|
|||
# Increase counter of attempts
|
||||
attempt_idx += 1
|
||||
|
||||
|
||||
def run_caller_task(t):
|
||||
global CURRENT_TASK
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue