feat: transcription module — faster-whisper with ROCm auto-detect
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import asyncio
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
||||
def test_transcription_engine_is_singleton():
|
||||
from transcription import engine, TranscriptionEngine
|
||||
assert isinstance(engine, TranscriptionEngine)
|
||||
|
||||
|
||||
def test_transcribe_file_calls_whisper(tmp_path):
|
||||
wav = tmp_path / "test.wav"
|
||||
wav.write_bytes(b"\x00" * 100)
|
||||
|
||||
mock_model = MagicMock()
|
||||
mock_segment = MagicMock()
|
||||
mock_segment.text = " Hallo Welt"
|
||||
mock_model.transcribe.return_value = ([mock_segment], MagicMock())
|
||||
|
||||
from transcription import TranscriptionEngine
|
||||
eng = TranscriptionEngine()
|
||||
eng._model = mock_model
|
||||
|
||||
result = asyncio.run(eng.transcribe_file(str(wav), language="de"))
|
||||
assert result == "Hallo Welt"
|
||||
mock_model.transcribe.assert_called_once_with(str(wav), language="de")
|
||||
Reference in New Issue
Block a user