- no more scheduled runs in offline mode - only interactive calls
This commit is contained in:
parent
cd9c250c95
commit
598456b830
|
|
@ -69,23 +69,23 @@ def detect_degraded_signal(file_test: Path, file_reference: Path) -> SignalBound
|
|||
# Seems some problem with recording, return zero boundaries
|
||||
return SignalBoundaries()
|
||||
|
||||
r = SignalBoundaries()
|
||||
if CONFIG.UseSpeechDetector:
|
||||
r = bt_signal.find_reference_signal_via_speechdetector(file_test)
|
||||
else:
|
||||
r = bt_signal.find_reference_signal(file_test)
|
||||
|
||||
if r.offset_start == 0.0 and is_caller:
|
||||
r.offset_start = 5.0 # Skip ringing tones
|
||||
|
||||
return r
|
||||
|
||||
|
||||
|
||||
def detect_reference_signal(file_reference: Path) -> SignalBoundaries:
|
||||
# Run silence eraser on reference file as well
|
||||
result = SignalBoundaries()
|
||||
if CONFIG.UseSpeechDetector:
|
||||
result = bt_signal.find_reference_signal_via_speechdetector(file_reference)
|
||||
else:
|
||||
result = bt_signal.find_reference_signal(file_reference)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
|
@ -358,6 +358,7 @@ def run_caller_task(t):
|
|||
# Runs caller probe - load task list and perform calls
|
||||
def run_probe():
|
||||
global TASK_LIST, CURRENT_TASK
|
||||
offline_mode : bool = False
|
||||
|
||||
while True:
|
||||
# Get task list update
|
||||
|
|
@ -366,6 +367,7 @@ def run_probe():
|
|||
# Check in cache
|
||||
utils.log('Checking for task list in cache...')
|
||||
new_tasks = CACHE.get_tasks(BACKEND.phone.name)
|
||||
offline_mode = True
|
||||
|
||||
# Did we fetch anything ?
|
||||
if new_tasks:
|
||||
|
|
@ -401,7 +403,9 @@ def run_probe():
|
|||
# Remove sheduled time
|
||||
del t['scheduled_time']
|
||||
|
||||
# Run task
|
||||
# Run task if we are online
|
||||
# Otherwise tasks run from the API point - via helper .apk
|
||||
if not offline_mode:
|
||||
run_caller_task(t)
|
||||
|
||||
utils.log_verbose(f'Call #{CALL_COUNTER.value} finished')
|
||||
|
|
@ -431,10 +435,13 @@ def run_probe():
|
|||
|
||||
if task is not None:
|
||||
run_caller_task(task)
|
||||
except:
|
||||
# Do nothing here, it is normal to get exception
|
||||
|
||||
except multiprocessing.Queue.empty:
|
||||
# Ignore this exception, this is normal
|
||||
pass
|
||||
except Exception as err:
|
||||
utils.log_error(message='Error when running t')
|
||||
|
||||
|
||||
# In case of empty task list wait 1 minute before refresh
|
||||
# if len(TASK_LIST.tasks) == 0:
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ def start():
|
|||
global ACCESS_POINT, SERVER_PROCESS
|
||||
|
||||
ACCESS_POINT.start()
|
||||
SERVER_PROCESS = multiprocessing.Process(target=web_process, args=(None,))
|
||||
SERVER_PROCESS = multiprocessing.Process(target=web_process, args=(None,), name='agent_gsm_web')
|
||||
SERVER_PROCESS.start()
|
||||
|
||||
def stop():
|
||||
|
|
|
|||
|
|
@ -6,36 +6,36 @@ import pathlib
|
|||
from utils_types import SignalBoundaries
|
||||
from utils_sevana import speech_detector
|
||||
|
||||
from pydub import silence, AudioSegment
|
||||
# from pydub import silence, AudioSegment
|
||||
|
||||
SILENCE_DELTA = 16
|
||||
|
||||
def find_reference_signal(input_file: pathlib.Path, output_file: pathlib.Path = None, use_end_offset: bool = True) -> SignalBoundaries:
|
||||
myaudio = AudioSegment.from_wav(str(input_file))
|
||||
dBFS = myaudio.dBFS
|
||||
# def find_reference_signal(input_file: pathlib.Path, output_file: pathlib.Path = None, use_end_offset: bool = True) -> SignalBoundaries:
|
||||
# myaudio = AudioSegment.from_wav(str(input_file))
|
||||
# dBFS = myaudio.dBFS
|
||||
|
||||
# Find silence intervals
|
||||
intervals = silence.detect_nonsilent(myaudio, min_silence_len=1000, silence_thresh=dBFS-SILENCE_DELTA, seek_step=50)
|
||||
# # Find silence intervals
|
||||
# intervals = silence.detect_nonsilent(myaudio, min_silence_len=1000, silence_thresh=dBFS-SILENCE_DELTA, seek_step=50)
|
||||
|
||||
# Translate to seconds
|
||||
intervals = [((start/1000),(stop/1000)) for start,stop in intervals] # in sec
|
||||
# # Translate to seconds
|
||||
# intervals = [((start/1000),(stop/1000)) for start,stop in intervals] # in sec
|
||||
|
||||
# print(intervals)
|
||||
# # print(intervals)
|
||||
|
||||
# Example of intervals: [(5.4, 6.4), (18.7, 37.05)]
|
||||
for p in intervals:
|
||||
if p[1] - p[0] > 17:
|
||||
bounds = SignalBoundaries(offset_start=p[0], offset_finish=p[1])
|
||||
if output_file is not None:
|
||||
signal = myaudio[bounds.offset_start * 1000 : bounds.offset_finish * 1000]
|
||||
signal.export(str(output_file), format='wav', parameters=['-ar', '44100', '-sample_fmt', 's16'])
|
||||
# # Example of intervals: [(5.4, 6.4), (18.7, 37.05)]
|
||||
# for p in intervals:
|
||||
# if p[1] - p[0] > 17:
|
||||
# bounds = SignalBoundaries(offset_start=p[0], offset_finish=p[1])
|
||||
# if output_file is not None:
|
||||
# signal = myaudio[bounds.offset_start * 1000 : bounds.offset_finish * 1000]
|
||||
# signal.export(str(output_file), format='wav', parameters=['-ar', '44100', '-sample_fmt', 's16'])
|
||||
|
||||
if use_end_offset:
|
||||
bounds.offset_finish = myaudio.duration_seconds - bounds.offset_finish
|
||||
# if use_end_offset:
|
||||
# bounds.offset_finish = myaudio.duration_seconds - bounds.offset_finish
|
||||
|
||||
return bounds
|
||||
# return bounds
|
||||
|
||||
return SignalBoundaries()
|
||||
# return SignalBoundaries()
|
||||
|
||||
|
||||
def find_reference_signal_via_speechdetector(input_file: pathlib.Path) -> SignalBoundaries:
|
||||
|
|
|
|||
Loading…
Reference in New Issue