feat: 字数限制2000 + MiniMax emotion参数 + 前端情绪全局选择模式

This commit is contained in:
lanhao
2026-06-30 23:47:23 +08:00
parent d6edc69c65
commit 81460f06d7
4 changed files with 57 additions and 104 deletions
+5 -3
View File
@@ -25,12 +25,13 @@ def synthesize():
pitch = data.get('pitch', 0)
volume = data.get('volume', 1.0)
instruction = data.get('instruction') # 用于CosyVoice的情绪指令
emotion = data.get('emotion', 'neutral') # 用于MiniMax的情绪参数
if not text.strip():
return jsonify({'error': '文本不能为空'}), 400
if len(text) > 500:
return jsonify({'error': '文本不能超过500字'}), 400
if len(text) > 2000:
return jsonify({'error': '文本不能超过2000字'}), 400
try:
if engine == 'cosyvoice':
@@ -46,7 +47,8 @@ def synthesize():
text=text,
speed=speed,
pitch=pitch,
volume=volume
volume=volume,
emotion=emotion
)
return jsonify({
+2 -1
View File
@@ -3,7 +3,7 @@ import base64
import requests
from io import BytesIO
def synthesize_minimax(text, speed=1.0, pitch=0, volume=1.0):
def synthesize_minimax(text, speed=1.0, pitch=0, volume=1.0, emotion='neutral'):
"""调用MiniMax TTS API"""
api_key = os.getenv('MINIMAX_API_KEY', '')
if not api_key:
@@ -27,6 +27,7 @@ def synthesize_minimax(text, speed=1.0, pitch=0, volume=1.0):
'speed': speed,
'vol': volume_int,
'pitch': pitch,
'emotion': emotion,
},
'audio_setting': {
'audio_sample_rate': 32000,