FlippFuzz commited on
Commit
5b766a2
1 Parent(s): 751fc8f

Add timestamp to generated output

Browse files

Example change:
```
Running whisper from 02:17.050 to 02:33.664 , duration: 16.613999999999976 expanded: 0.0 prompt: None language: ja
[00:00:00.000->00:00:03.400] Ah, no, ah, ha
[00:00:03.400->00:00:06.600] Everyone, it's Kou-kun!
[00:00:06.600->00:00:08.400] Good evening!
```
This pull request adds the start and end time from the raw segments returned by Whisper.

src/whisper/fasterWhisperContainer.py CHANGED
@@ -7,6 +7,7 @@ from src.hooks.progressListener import ProgressListener
7
  from src.languages import get_language_from_name
8
  from src.modelCache import ModelCache
9
  from src.whisper.abstractWhisperContainer import AbstractWhisperCallback, AbstractWhisperContainer
 
10
 
11
  class FasterWhisperContainer(AbstractWhisperContainer):
12
  def __init__(self, model_name: str, device: str = None, compute_type: str = "float16",
@@ -138,7 +139,8 @@ class FasterWhisperCallback(AbstractWhisperCallback):
138
  if progress_listener is not None:
139
  progress_listener.on_progress(segment.end, info.duration)
140
  if verbose:
141
- print(segment.text)
 
142
 
143
  text = " ".join([segment.text for segment in segments])
144
 
 
7
  from src.languages import get_language_from_name
8
  from src.modelCache import ModelCache
9
  from src.whisper.abstractWhisperContainer import AbstractWhisperCallback, AbstractWhisperContainer
10
+ from src.utils import format_timestamp
11
 
12
  class FasterWhisperContainer(AbstractWhisperContainer):
13
  def __init__(self, model_name: str, device: str = None, compute_type: str = "float16",
 
139
  if progress_listener is not None:
140
  progress_listener.on_progress(segment.end, info.duration)
141
  if verbose:
142
+ print("[{}->{}]{}".format(format_timestamp(segment.start, True), format_timestamp(segment.end, True),
143
+ segment.text))
144
 
145
  text = " ".join([segment.text for segment in segments])
146