- no more scheduled runs in offline mode - only interactive calls
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user