fix: CosyVoice补全语速/声调/音量参数

三个引擎的滑块参数现在全部生效

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
lanhao
2026-07-02 21:44:30 +08:00
parent dbdb032adb
commit c44fa711a7
+10
View File
@@ -13,6 +13,11 @@ def synthesize_cosyvoice(text, speed=1.0, pitch=0, volume=1.0, instruction=None)
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
# 前端 pitch: -12~12 → API rate: 0.5~2.0(以1.0为中心)
pitch_ratio = max(0.5, min(2.0, 1.0 + pitch / 24))
# 前端 volume: 0~10 → API volume: 0~100
volume_int = int(max(0, min(100, volume * 10)))
payload = { payload = {
'model': 'cosyvoice-v3.5-flash', 'model': 'cosyvoice-v3.5-flash',
'input': { 'input': {
@@ -20,6 +25,11 @@ def synthesize_cosyvoice(text, speed=1.0, pitch=0, volume=1.0, instruction=None)
'voice': 'cosyvoice-v3.5-flash-bailian-e859a6e87823419f9c6b3eefb1a97dc3', 'voice': 'cosyvoice-v3.5-flash-bailian-e859a6e87823419f9c6b3eefb1a97dc3',
'format': 'mp3', 'format': 'mp3',
'sample_rate': 32000 'sample_rate': 32000
},
'parameters': {
'rate': max(0.5, min(2.0, speed)),
'pitch': pitch_ratio,
'volume': volume_int
} }
} }