mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
fix(mimo): 修复voice design模型请求中包含无效voice参数的问题 (#8326)
* fix(mimo): 修复voice design模型请求中包含无效voice参数的问题 - voice design模型不支持audio.voice参数,之前统一添加导致请求可能出错 - 在构建请求payload时根据模型名称动态决定是否包含voice字段 - 增加单元测试覆盖voicedesign模型和普通模型的参数构建逻辑 close #8283 * style: 使用snake case命名法
This commit is contained in:
@@ -88,13 +88,15 @@ class ProviderMiMoTTSAPI(TTSProvider):
|
||||
}
|
||||
)
|
||||
|
||||
audio_params = {"format": self.audio_format}
|
||||
# voice design 模型不支持 audio.voice 参数
|
||||
if "voicedesign" not in self.model_name:
|
||||
audio_params["voice"] = self.voice
|
||||
|
||||
return {
|
||||
"model": self.model_name,
|
||||
"messages": messages,
|
||||
"audio": {
|
||||
"format": self.audio_format,
|
||||
"voice": self.voice,
|
||||
},
|
||||
"audio": audio_params,
|
||||
}
|
||||
|
||||
async def get_audio(self, text: str) -> str:
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user