From 5c4d22ef8fc41095d19ab20dcd8c597ca2616f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=94=A6=E5=BC=BA?= <1061669148@qq.com> Date: Tue, 11 Mar 2025 14:20:52 +0800 Subject: [PATCH] feat: update voice mapping logic to prioritize request voice over default --- internal/http/handlers/tts.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/http/handlers/tts.go b/internal/http/handlers/tts.go index 9048e9f..fc0b37b 100644 --- a/internal/http/handlers/tts.go +++ b/internal/http/handlers/tts.go @@ -65,12 +65,9 @@ func (h *TTSHandler) HandleOpenAITTS(w http.ResponseWriter, r *http.Request) { } // 映射OpenAI声音到Microsoft声音 - msVoice := h.config.TTS.DefaultVoice - if openaiReq.Voice != "" { - // 检查是否有配置映射 - if mappedVoice, exists := h.config.TTS.VoiceMapping[openaiReq.Voice]; exists { - msVoice = mappedVoice - } + msVoice := openaiReq.Voice + if openaiReq.Voice != "" && h.config.TTS.VoiceMapping[openaiReq.Voice] != "" { + msVoice = h.config.TTS.VoiceMapping[openaiReq.Voice] } // 转换速度参数到微软格式