fix(voice): correct yandex asr endpoints
This commit is contained in:
@@ -132,7 +132,7 @@ def test_yandex_asr_provider_supports_kz_v3_async_rest(monkeypatch):
|
||||
|
||||
def post(self, url: str, *, headers: dict[str, str], json: dict) -> _DummyResponse:
|
||||
calls.append({"method": "POST", "url": url, "headers": headers, "json": json})
|
||||
return _DummyResponse({"id": "operation-1", "done": True})
|
||||
return _DummyResponse({"id": "operation-1", "done": False})
|
||||
|
||||
def get(
|
||||
self,
|
||||
@@ -142,6 +142,8 @@ def test_yandex_asr_provider_supports_kz_v3_async_rest(monkeypatch):
|
||||
params: dict[str, str] | None = None,
|
||||
) -> _DummyResponse:
|
||||
calls.append({"method": "GET", "url": url, "headers": headers, "params": params or {}})
|
||||
if "operation.api.cloud.yandex.net/operations/" in url:
|
||||
return _DummyResponse({"id": "operation-1", "done": True})
|
||||
return _DummyResponse(
|
||||
{
|
||||
"finalRefinement": {
|
||||
@@ -158,6 +160,7 @@ def test_yandex_asr_provider_supports_kz_v3_async_rest(monkeypatch):
|
||||
|
||||
monkeypatch.setenv("AI_VOICE_ASR_YANDEX_API_KEY", "asr-key")
|
||||
monkeypatch.setenv("AI_VOICE_ASR_YANDEX_API_BASE", "https://stt.api.ml.yandexcloud.kz")
|
||||
monkeypatch.delenv("AI_VOICE_ASR_YANDEX_OPERATIONS_BASE", raising=False)
|
||||
monkeypatch.setenv("AI_VOICE_ASR_YANDEX_FOLDER_ID", "folder-test")
|
||||
monkeypatch.setenv("AI_VOICE_ASR_YANDEX_POLL_INTERVAL_SECONDS", "0.05")
|
||||
monkeypatch.setattr(asr_module.httpx, "Client", _DummyClient)
|
||||
@@ -167,14 +170,16 @@ def test_yandex_asr_provider_supports_kz_v3_async_rest(monkeypatch):
|
||||
|
||||
assert result.text == "almaty schedule"
|
||||
assert result.language == "ru-RU"
|
||||
assert calls[0]["url"] == "https://stt.api.ml.yandexcloud.kz/stt/v3/recognizeFileAsync"
|
||||
assert calls[0]["url"] == "https://stt.api.cloud.yandex.net/stt/v3/recognizeFileAsync"
|
||||
assert calls[0]["headers"]["Authorization"] == "Api-Key asr-key"
|
||||
assert calls[0]["headers"]["Content-Type"] == "application/json"
|
||||
assert calls[0]["headers"]["x-folder-id"] == "folder-test"
|
||||
assert calls[0]["json"]["recognitionModel"]["audioFormat"]["rawAudio"]["sampleRateHertz"] == "8000"
|
||||
assert calls[0]["json"]["recognitionModel"]["languageRestriction"]["languageCode"] == ["ru-RU"]
|
||||
assert calls[1]["url"] == "https://stt.api.ml.yandexcloud.kz/stt/v3/getRecognition"
|
||||
assert calls[1]["params"] == {"operationId": "operation-1"}
|
||||
assert calls[1]["url"] == "https://operation.api.cloud.yandex.net/operations/operation-1"
|
||||
assert calls[1]["params"] == {}
|
||||
assert calls[2]["url"] == "https://stt.api.cloud.yandex.net/stt/v3/getRecognition"
|
||||
assert calls[2]["params"] == {"operationId": "operation-1"}
|
||||
|
||||
|
||||
def test_yandex_buffered_streaming_provider_buffers_pcm_until_finalize():
|
||||
|
||||
Reference in New Issue
Block a user