From 649a52c07bbf66752491ad1ee5e6b179f41696a2 Mon Sep 17 00:00:00 2001 From: bdim404 Date: Thu, 12 Mar 2026 14:10:17 +0800 Subject: [PATCH] feat: Add emotion control feature with presets and intensity adjustment in CustomVoiceForm --- .../src/components/tts/CustomVoiceForm.tsx | 79 ++++++++++++++----- .../src/components/ui/select.tsx | 2 +- 2 files changed, 59 insertions(+), 22 deletions(-) diff --git a/qwen3-tts-frontend/src/components/tts/CustomVoiceForm.tsx b/qwen3-tts-frontend/src/components/tts/CustomVoiceForm.tsx index 93320f4..f3fe653 100644 --- a/qwen3-tts-frontend/src/components/tts/CustomVoiceForm.tsx +++ b/qwen3-tts-frontend/src/components/tts/CustomVoiceForm.tsx @@ -63,8 +63,21 @@ const CustomVoiceForm = forwardRef((_props, ref) => { const [isLoading, setIsLoading] = useState(false) const [advancedOpen, setAdvancedOpen] = useState(false) const [indexTTS2Open, setIndexTTS2Open] = useState(false) + const [selectedEmotion, setSelectedEmotion] = useState('none') const [emoText, setEmoText] = useState('') const [emoAlpha, setEmoAlpha] = useState(0.6) + + const EMOTION_PRESETS = [ + { value: 'none', label: '不使用情感控制', emo_text: '', emo_alpha: 0.5 }, + { value: 'happy', label: '开心', emo_text: '开心', emo_alpha: 0.6 }, + { value: 'angry', label: '愤怒', emo_text: '愤怒', emo_alpha: 0.15 }, + { value: 'sad', label: '悲伤', emo_text: '悲伤', emo_alpha: 0.6 }, + { value: 'fear', label: '恐惧', emo_text: '恐惧', emo_alpha: 0.6 }, + { value: 'hate', label: '厌恶', emo_text: '厌恶', emo_alpha: 0.6 }, + { value: 'low', label: '低沉', emo_text: '低沉', emo_alpha: 0.6 }, + { value: 'surprise', label: '惊讶', emo_text: '惊讶', emo_alpha: 0.3 }, + { value: 'neutral', label: '中性', emo_text: '中性', emo_alpha: 0.5 }, + ] const [isIndexTTS2Loading, setIsIndexTTS2Loading] = useState(false) const [tempAdvancedParams, setTempAdvancedParams] = useState({ max_new_tokens: 2048, @@ -555,35 +568,59 @@ const CustomVoiceForm = forwardRef((_props, ref) => { - IndexTTS2 - 使用 IndexTTS2 合成,支持情感控制 + 情感控制 + 使用 IndexTTS2 合成,选择情感预设
- -