Keep segment timestamps aligned with words timestamps after VAD (#119)

This commit is contained in:
Guillaume Klein
2023-04-06 11:54:40 +02:00
committed by GitHub
parent 051b3350e5
commit e9a082dcf2

View File

@@ -776,14 +776,18 @@ def restore_speech_timestamps(
end=ts_map.get_original_time(word.end, chunk_index),
)
words.append(word)
else:
words = segment.words
segment = segment._replace(
start=ts_map.get_original_time(segment.start),
end=ts_map.get_original_time(segment.end),
words=words,
)
segment = segment._replace(
start=words[0].start,
end=words[-1].end,
words=words,
)
else:
segment = segment._replace(
start=ts_map.get_original_time(segment.start),
end=ts_map.get_original_time(segment.end),
)
yield segment