From fb4baf676fd5ddf0b25963e70a633031f36ad03d Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 28 Dec 2025 00:34:44 +0800 Subject: [PATCH] perf: add `auto` voice emotion for minimax tts (#4228) * perf: add `auto` voice emotion for minimax tts * ruff format --- astrbot/core/config/default.py | 9 ++++++--- astrbot/core/provider/sources/minimax_tts_api_source.py | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index d81662adf..f10678bf7 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -1286,7 +1286,7 @@ CONFIG_METADATA_2 = { "minimax-is-timber-weight": False, "minimax-voice-id": "female-shaonv", "minimax-timber-weight": '[\n {\n "voice_id": "Chinese (Mandarin)_Warm_Girl",\n "weight": 25\n },\n {\n "voice_id": "Chinese (Mandarin)_BashfulGirl",\n "weight": 50\n }\n]', - "minimax-voice-emotion": "neutral", + "minimax-voice-emotion": "auto", "minimax-voice-latex": False, "minimax-voice-english-normalization": False, "timeout": 20, @@ -1858,15 +1858,18 @@ CONFIG_METADATA_2 = { "minimax-voice-emotion": { "type": "string", "description": "情绪", - "hint": "控制合成语音的情绪", + "hint": "控制合成语音的情绪。当为 auto 时,将根据文本内容自动选择情绪。", "options": [ + "auto", "happy", "sad", "angry", "fearful", "disgusted", "surprised", - "neutral", + "calm", + "fluent", + "whisper", ], }, "minimax-voice-latex": { diff --git a/astrbot/core/provider/sources/minimax_tts_api_source.py b/astrbot/core/provider/sources/minimax_tts_api_source.py index 9e2d665c7..dcd29060e 100644 --- a/astrbot/core/provider/sources/minimax_tts_api_source.py +++ b/astrbot/core/provider/sources/minimax_tts_api_source.py @@ -51,7 +51,7 @@ class ProviderMiniMaxTTSAPI(TTSProvider): "voice_id": "" if self.is_timber_weight else provider_config.get("minimax-voice-id", ""), - "emotion": provider_config.get("minimax-voice-emotion", "neutral"), + "emotion": provider_config.get("minimax-voice-emotion", "auto"), "latex_read": provider_config.get("minimax-voice-latex", False), "english_normalization": provider_config.get( "minimax-voice-english-normalization", @@ -59,6 +59,9 @@ class ProviderMiniMaxTTSAPI(TTSProvider): ), } + if self.voice_setting["emotion"] == "auto": + self.voice_setting.pop("emotion", None) + self.audio_setting: dict = { "sample_rate": 32000, "bitrate": 128000,