Skip to content

Commit

Permalink
Merge pull request #2 from SYSTRAN/master
Browse files Browse the repository at this point in the history
fix: Use correct `seek` value in output, fix word timestamps when the initial timestamp is not zero (SYSTRAN#1141)
  • Loading branch information
BitSteve authored Nov 15, 2024
2 parents 85e61ea + 53bbe54 commit 8a1c1df
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions faster_whisper/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def forward(self, features, chunks_metadata, **forward_params):
compression_ratio=get_compression_ratio(
self.tokenizer.decode(subsegment["tokens"])
),
seek=int(
chunk_metadata["start_time"] * self.model.frames_per_second
),
)
for subsegment in subsegments
]
Expand Down Expand Up @@ -496,7 +499,7 @@ def _batched_segments_generator(
for segment in result:
seg_idx += 1
yield Segment(
seek=int(result[-1]["end"] * self.model.frames_per_second),
seek=segment["seek"],
id=seg_idx,
text=segment["text"],
start=round(segment["start"], 3),
Expand Down Expand Up @@ -1318,7 +1321,7 @@ def next_words_segment(segments: List[dict]) -> Optional[dict]:

yield Segment(
id=idx,
seek=seek,
seek=previous_seek,
start=segment["start"],
end=segment["end"],
text=text,
Expand Down Expand Up @@ -1585,7 +1588,7 @@ def add_word_timestamps(

for segment_idx, segment in enumerate(segments):
word_index = 0
time_offset = segment[0]["start"]
time_offset = segment[0]["seek"] / self.frames_per_second
median_duration, max_duration = median_max_durations[segment_idx]
for subsegment_idx, subsegment in enumerate(segment):
saved_tokens = 0
Expand Down

0 comments on commit 8a1c1df

Please sign in to comment.