From 716afad04610187d36dbf108dda771b2e4567040 Mon Sep 17 00:00:00 2001 From: NayukiMeko Date: Mon, 25 May 2026 19:25:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(mimo):=20=E4=BF=AE=E5=A4=8Dvoice=20desi?= =?UTF-8?q?gn=E6=A8=A1=E5=9E=8B=E8=AF=B7=E6=B1=82=E4=B8=AD=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E6=97=A0=E6=95=88voice=E5=8F=82=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - voice design模型不支持audio.voice参数,之前统一添加导致请求可能出错 - 在构建请求payload时根据模型名称动态决定是否包含voice字段 - 增加单元测试覆盖voicedesign模型和普通模型的参数构建逻辑 close #8283 --- .../provider/sources/mimo_tts_api_source.py | 10 +++--- tests/test_mimo_api_sources.py | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/astrbot/core/provider/sources/mimo_tts_api_source.py b/astrbot/core/provider/sources/mimo_tts_api_source.py index 2966bfb7d8..08af9cfaf5 100644 --- a/astrbot/core/provider/sources/mimo_tts_api_source.py +++ b/astrbot/core/provider/sources/mimo_tts_api_source.py @@ -88,13 +88,15 @@ def _build_payload(self, text: str) -> dict: } ) + audioParams = {"format": self.audio_format} + # voice design 模型不支持 audio.voice 参数 + if "voicedesign" not in self.model_name: + audioParams["voice"] = self.voice + return { "model": self.model_name, "messages": messages, - "audio": { - "format": self.audio_format, - "voice": self.voice, - }, + "audio": audioParams, } async def get_audio(self, text: str) -> str: diff --git a/tests/test_mimo_api_sources.py b/tests/test_mimo_api_sources.py index c2b02aa136..ec5b674534 100644 --- a/tests/test_mimo_api_sources.py +++ b/tests/test_mimo_api_sources.py @@ -129,6 +129,39 @@ def test_mimo_tts_seed_text_is_not_prepended_to_assistant_content(): asyncio.run(provider.terminate()) +def test_mimo_tts_voicedesign_model_omits_voice_param(): + """voice design 模型不应包含 audio.voice 参数""" + provider = _make_tts_provider( + { + "model": "mimo-v2.5-tts-voicedesign", + "mimo-tts-seed-text": "", + } + ) + try: + payload = provider._build_payload("hello") + assert "voice" not in payload["audio"] + assert payload["audio"]["format"] == "wav" + finally: + asyncio.run(provider.terminate()) + + +def test_mimo_tts_regular_model_includes_voice_param(): + """普通 TTS 模型应包含 audio.voice 参数""" + provider = _make_tts_provider( + { + "model": "mimo-v2.5-tts", + "mimo-tts-voice": "custom_voice", + "mimo-tts-seed-text": "", + } + ) + try: + payload = provider._build_payload("hello") + assert payload["audio"]["voice"] == "custom_voice" + assert payload["audio"]["format"] == "wav" + finally: + asyncio.run(provider.terminate()) + + def test_mimo_headers_use_single_authorization_method(): assert build_headers("test-key") == { "Content-Type": "application/json", From 338772353eb29a9f50809b86890f9f67243eed86 Mon Sep 17 00:00:00 2001 From: NayukiMeko Date: Mon, 25 May 2026 19:58:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?style:=20=E4=BD=BF=E7=94=A8snake=20case?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/provider/sources/mimo_tts_api_source.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/astrbot/core/provider/sources/mimo_tts_api_source.py b/astrbot/core/provider/sources/mimo_tts_api_source.py index 08af9cfaf5..63389a10b6 100644 --- a/astrbot/core/provider/sources/mimo_tts_api_source.py +++ b/astrbot/core/provider/sources/mimo_tts_api_source.py @@ -88,15 +88,15 @@ def _build_payload(self, text: str) -> dict: } ) - audioParams = {"format": self.audio_format} + audio_params = {"format": self.audio_format} # voice design 模型不支持 audio.voice 参数 if "voicedesign" not in self.model_name: - audioParams["voice"] = self.voice + audio_params["voice"] = self.voice return { "model": self.model_name, "messages": messages, - "audio": audioParams, + "audio": audio_params, } async def get_audio(self, text: str) -> str: