clamp end_timestamp to prevent infinite loop

This commit is contained in:
m-bain
2023-04-11 20:15:37 +01:00
committed by GitHub
parent 48ed89834e
commit 6a72b61564

View File

@ -269,6 +269,10 @@ def transcribe(
end_timestamp_pos = (
sliced_tokens[-1].item() - tokenizer.timestamp_begin
)
# clamp end-time to at least be 1 frame after start-time
end_timestamp_pos = max(end_timestamp_pos, start_timestamp_pos + time_precision)
current_segments.append(
new_segment(
start=time_offset + start_timestamp_pos * time_precision,
@ -426,4 +430,4 @@ def transcribe_with_vad(
output["language"] = output["segments"][0]["language"]
return output
return output