Repository: SYSTRAN/faster-whisper
Issue category: Bug Report

Some segment has a 1 second shifted after PR #856
appreciate your hard work

---

audio (2 minutes): [01.aac.zip](https://github.com/user-attachments/files/17751633/01.aac.zip)

The correct SRT result (using commit fbcf58b, which is before the huge PR #856): [01.old.srt.zip](https://github.com/user-attachments/files/17751733/01.old.srt.zip)

The wrong SRT result (using latest commit 85e61ea): [01.new.srt.zip](https://github.com/user-attachments/files/17751755/01.new.srt.zip)

---

I am **not** using the batch version

```python
model = faster_whisper.WhisperModel(
    model_size_or_path='large-v2',
    device='cuda',
    cpu_threads=4,
)
model.transcribe(
    audio=audio,
    language=None,
    task='transcribe',
    vad_filter=False,
    initial_prompt=None,
    word_timestamps=True,
    repetition_penalty=1.0,
)
```

script from this project https://github.com/heimoshuiyu/whisper-fastapi

---

![image](https://github.com/user-attachments/assets/d679ce1b-8771-4310-aadd-ef5c8ab7f886)

some segments on the left (wrong) has 1 second mismatch (shift +1s) than the right (correct)

---

I also test on the commit of RP #856 (eb839023), which is worse

result SRT: 
[01.eb839023.srt.zip](https://github.com/user-attachments/files/17752205/01.eb839023.srt.zip)

![image](https://github.com/user-attachments/assets/cd958dfb-fb15-4b08-ac4a-0e66f7cd0f3d)

left: commit eb839023 PR #856
middle: latest commit 85e61ea
right: commit fbcf58b



Functions to edit:
faster_whisper/transcribe.py:BatchedInferencePipeline.forward
faster_whisper/transcribe.py:BatchedInferencePipeline._batched_segments_generator
faster_whisper/transcribe.py:WhisperModel.generate_segments
faster_whisper/transcribe.py:WhisperModel.add_word_timestamps

Patch:
diff --git a/faster_whisper/transcribe.py b/faster_whisper/transcribe.py
index 6d18a173..80e5d92c 100644
--- a/faster_whisper/transcribe.py
+++ b/faster_whisper/transcribe.py
@@ -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
                 ]
@@ -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),
@@ -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,
@@ -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