From 034c7fd9e2758b8758537da4908d5fdce95a659a Mon Sep 17 00:00:00 2001 From: Philipp Mandler Date: Thu, 28 Sep 2023 11:59:12 +0200 Subject: [PATCH] Fix unpacking None value in alignment fixes #352 --- worker/transcribee_worker/torchaudio_align.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/worker/transcribee_worker/torchaudio_align.py b/worker/transcribee_worker/torchaudio_align.py index 4d37b87a..fd07589e 100644 --- a/worker/transcribee_worker/torchaudio_align.py +++ b/worker/transcribee_worker/torchaudio_align.py @@ -183,7 +183,12 @@ def work(queue, audio): # Atoms). # We might want to consider not counting the word separator to the timing of a atom. - atom_index_to_timing_index = [] + atom_index_to_timing_index: list[ + tuple[ + tuple[int | None, int] | None, + tuple[int | None, int] | None, + ] + ] = [] tokens = [] for atom in atoms: @@ -257,7 +262,11 @@ def work(queue, audio): waveform_segment.size(1) / (trellis.size(0) - 1) ) / settings.SAMPLE_RATE for i, atom in enumerate(atoms): - (start, last_end), (end, next_start) = atom_index_to_timing_index[i] + start_info, end_info = atom_index_to_timing_index[i] + if start_info is None or end_info is None: + continue + + (start, last_end), (end, next_start) = start_info, end_info if start is None: if last_end < 0: