DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(voice): hide unsupported DashScope 8k STT option
Bingxi Zhao (Frank)7adef0b607ae
diff --git a/deeptutor/services/voice/adapters/dashscope.py b/deeptutor/services/voice/adapters/dashscope.pyindex 3f7b0fb58..b5b034eb6 100644--- a/deeptutor/services/voice/adapters/dashscope.py+++ b/deeptutor/services/voice/adapters/dashscope.py@@ -135,6 +135,11 @@ class DashScopeSTTAdapter(BaseSTTAdapter):) -> str:if not audio:raise VoiceProviderError("No audio data to transcribe.")+ if config.model in {"paraformer-realtime-8k-v1", "paraformer-realtime-8k-v2"}:+ raise VoiceProviderError(+ "DashScope 8k realtime models require 8000 Hz audio; "+ "select paraformer-realtime-v2 for the 16000 Hz voice adapter."+ )wav_audio = await self._prepare_wav(audio, filename, content_type)if not wav_audio:raise VoiceProviderError("Audio conversion returned an empty file.")diff --git a/deeptutor/services/voice/options.py b/deeptutor/services/voice/options.pyindex 29ddf29fd..84ab11779 100644--- a/deeptutor/services/voice/options.py+++ b/deeptutor/services/voice/options.py@@ -201,7 +201,7 @@ def voice_options(provider: str, service: str) -> dict:"openrouter": ["openai/whisper-large-v3"],"groq": ["whisper-large-v3-turbo", "whisper-large-v3"],"siliconflow": ["FunAudioLLM/SenseVoiceSmall"],- "dashscope": ["paraformer-realtime-v2", "paraformer-realtime-8k-v2"],+ "dashscope": ["paraformer-realtime-v2"],"volcengine_speech": ["bigmodel"],}.get(provider, [])languages = VOLC_LANGUAGES if provider == "volcengine_speech" else ISO_LANGUAGESdiff --git a/tests/services/test_voice.py b/tests/services/test_voice.pyindex 115624c2c..77e40d306 100644--- a/tests/services/test_voice.py+++ b/tests/services/test_voice.py@@ -31,12 +31,14 @@ from deeptutor.services.voice.adapters.openai_compat import (OpenRouterTTSAdapter,)from deeptutor.services.voice.base import (+ VoiceProviderError,build_auth_headers,join_audio_path,normalize_stt_content_type,strip_markdown_for_speech,)from deeptutor.services.voice.config import STTConfig, TTSConfig+from deeptutor.services.voice.options import voice_optionsdef _capture_post(monkeypatch: pytest.MonkeyPatch, response: httpx.Response) -> dict[str, Any]:@@ -488,6 +490,18 @@ def test_dashscope_stt_url_and_errors() -> None:assert adapter._sentence_texts({"sentence": {"text": "single"}}) == ["single"]+def test_dashscope_stt_options_only_offer_supported_sample_rate() -> None:+ models = voice_options("dashscope", "stt")["models"]+ assert [model["id"] for model in models] == ["paraformer-realtime-v2"]+++async def test_dashscope_stt_rejects_8k_model_before_audio_conversion() -> None:+ config = STTConfig(model="paraformer-realtime-8k-v2", api_key="dash-key")+ with pytest.raises(VoiceProviderError, match="require 8000 Hz audio"):+ await DashScopeSTTAdapter().transcribe(b"audio", config)++@pytest.mark.asyncioasync def test_stt_adapter_openrouter_base64(monkeypatch: pytest.MonkeyPatch) -> None:resp = httpx.Response(200, json={"text": "from base64"})