From d3a5e1a58ed00b694a0c086e70279c86397d5775 Mon Sep 17 00:00:00 2001 From: Jeronymous Date: Mon, 25 Nov 2024 04:45:31 +0100 Subject: [PATCH] Fixes #223 : update code to work with auditok>0.2.0 --- whisper_timestamped/transcribe.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/whisper_timestamped/transcribe.py b/whisper_timestamped/transcribe.py index 2d62e6b..6dfd143 100755 --- a/whisper_timestamped/transcribe.py +++ b/whisper_timestamped/transcribe.py @@ -3,7 +3,7 @@ __author__ = "Jérôme Louradour" __credits__ = ["Jérôme Louradour"] __license__ = "GPLv3" -__version__ = "1.15.6" +__version__ = "1.15.7" # Set some environment variables import os @@ -2044,7 +2044,14 @@ def apply_folder_hack(): drop_trailing_silence=True, ) - segments = [{"start": s._meta.start * sample_rate, "end": s._meta.end * sample_rate} for s in segments] + if auditok.__version__ >= "0.3.0": + def auditok_segment_to_dict(s): + return {"start": s.start * sample_rate, "end": s.end * sample_rate} + else: + def auditok_segment_to_dict(s): + return {"start": s._meta.start * sample_rate, "end": s._meta.end * sample_rate} + + segments = [auditok_segment_to_dict(s) for s in segments] else: raise ValueError(f"Got unexpected VAD method {method}")