feat: remote Whisper via whisper.base_url — OpenAI-compatible upload
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
||||
@@ -23,3 +24,26 @@ def test_transcribe_file_calls_whisper(tmp_path):
|
||||
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")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_transcribe_uses_remote_when_base_url_set(tmp_path):
|
||||
import wave, struct
|
||||
wav = tmp_path / "test.wav"
|
||||
with wave.open(str(wav), "wb") as wf:
|
||||
wf.setnchannels(1); wf.setsampwidth(2); wf.setframerate(16000)
|
||||
wf.writeframes(struct.pack("<100h", *([0] * 100)))
|
||||
|
||||
import respx, httpx
|
||||
from transcription import TranscriptionEngine
|
||||
eng = TranscriptionEngine()
|
||||
|
||||
with respx.mock:
|
||||
respx.post("http://beastix:8000/v1/audio/transcriptions").mock(
|
||||
return_value=httpx.Response(200, json={"text": "Hallo Welt"})
|
||||
)
|
||||
result = await eng.transcribe_file(
|
||||
str(wav), language="de", model_name="large-v3",
|
||||
device="auto", base_url="http://beastix:8000",
|
||||
)
|
||||
assert result == "Hallo Welt"
|
||||
|
||||
Reference in New Issue
Block a user