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>
26 lines
713 B
Python
26 lines
713 B
Python
import unittest
|
|
|
|
import transcript_utils
|
|
|
|
|
|
class TestTranscriptUtils(unittest.TestCase):
|
|
def test_diarization_requires_hugging_face_token(self):
|
|
with self.assertRaisesRegex(
|
|
ValueError,
|
|
"HF_TOKEN is required for WhisperX diarization",
|
|
):
|
|
transcript_utils.require_diarization_token(True, None)
|
|
|
|
def test_diarization_does_not_require_token_when_disabled(self):
|
|
transcript_utils.require_diarization_token(False, None)
|
|
|
|
def test_seconds_are_serialized_as_nanoseconds(self):
|
|
self.assertEqual(
|
|
transcript_utils.seconds_to_nanoseconds(3.25),
|
|
3_250_000_000,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|