From 987c5ff29c2dc44070bdfbd3fb5aac4c536fc097 Mon Sep 17 00:00:00 2001 From: Jeronymous Date: Mon, 29 Jan 2024 13:27:09 +0100 Subject: [PATCH] Fix auditok corner case --- whisper_timestamped/transcribe.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/whisper_timestamped/transcribe.py b/whisper_timestamped/transcribe.py index b48ecf0..cd29896 100755 --- a/whisper_timestamped/transcribe.py +++ b/whisper_timestamped/transcribe.py @@ -1978,14 +1978,16 @@ def apply_folder_hack(): data = (audio.numpy() * 32767).astype(np.int16).tobytes() + audio_duration = len(audio) / SAMPLE_RATE + segments = auditok.split( data, sampling_rate=SAMPLE_RATE, # sampling frequency in Hz channels=1, # number of channels sample_width=2, # number of bytes per sample min_dur=min_speech_duration, # minimum duration of a valid audio event in seconds - max_dur=len(audio)/SAMPLE_RATE, # maximum duration of an event - max_silence=min_silence_duration, # maximum duration of tolerated continuous silence within an event + max_dur=audio_duration, # maximum duration of an event + max_silence=min(audio_duration*.95, min_silence_duration), # maximum duration of tolerated continuous silence within an event energy_threshold=50, drop_trailing_silence=True, )