mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-12 14:22:11 -04:00
WhisperX silently returned a plain transcript when diarization lacked the Hugging Face token required to load pyannote. Reject that request clearly so callers do not mistake missing speaker labels for a successful diarization. Convert WhisperX seconds to the nanosecond duration unit used by the transcription API. Assisted-by: Codex:gpt-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
13 lines
432 B
Python
13 lines
432 B
Python
"""Helpers for WhisperX transcript responses."""
|
|
|
|
|
|
def require_diarization_token(diarize, token):
|
|
"""Reject diarization when WhisperX cannot load its gated pipeline."""
|
|
if diarize and not token:
|
|
raise ValueError("HF_TOKEN is required for WhisperX diarization")
|
|
|
|
|
|
def seconds_to_nanoseconds(seconds):
|
|
"""Convert WhisperX timestamps to the duration unit used by LocalAI."""
|
|
return int(seconds * 1_000_000_000)
|