Add word-level timestamps and confidence scores
- New word_timestamps option (default False) in client handshake - When enabled, each segment includes 'words' array with per-word start/end times and probability scores - Wired through entire pipeline: client → server → backend → transcribe() - Words include timestamp_offset for accurate absolute times - REST API already supported word timestamps; now WebSocket does too - Added 9 unit tests for word timestamp extraction and formatting
This commit is contained in:
@@ -36,6 +36,7 @@ class ServeClientFasterWhisper(ServeClientBase):
|
||||
translation_queue=None,
|
||||
hotwords=None,
|
||||
diarization=None,
|
||||
word_timestamps=False,
|
||||
):
|
||||
"""
|
||||
Initialize a ServeClient instance.
|
||||
@@ -67,6 +68,7 @@ class ServeClientFasterWhisper(ServeClientBase):
|
||||
same_output_threshold,
|
||||
translation_queue,
|
||||
diarization,
|
||||
word_timestamps,
|
||||
)
|
||||
self.cache_path = cache_path
|
||||
self.model_sizes = [
|
||||
@@ -217,6 +219,7 @@ class ServeClientFasterWhisper(ServeClientBase):
|
||||
initial_prompt=self.initial_prompt,
|
||||
use_vad=self.use_vad,
|
||||
vad_parameters=self.vad_parameters if self.use_vad else None,
|
||||
word_timestamps=self.word_timestamps,
|
||||
)
|
||||
ServeClientFasterWhisper.BATCH_WORKER.submit(request)
|
||||
request.future.wait(timeout=30)
|
||||
@@ -236,7 +239,8 @@ class ServeClientFasterWhisper(ServeClientBase):
|
||||
task=self.task,
|
||||
vad_filter=self.use_vad,
|
||||
vad_parameters=self.vad_parameters if self.use_vad else None,
|
||||
hotwords=self.hotwords)
|
||||
hotwords=self.hotwords,
|
||||
word_timestamps=self.word_timestamps)
|
||||
if ServeClientFasterWhisper.SINGLE_MODEL:
|
||||
ServeClientFasterWhisper.SINGLE_MODEL_LOCK.release()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user