feat: 增强音频播放管理,新增 TTSPlayManager 类,优化流式语音合成逻辑,支持 PCM 数据和 base64 转换

This commit is contained in:
EvanWu
2025-08-21 13:47:58 +08:00
parent 16c3255e99
commit bf999b91a5
4 changed files with 266 additions and 184 deletions

View File

@@ -1340,12 +1340,15 @@ function _Chat() {
});
try {
for await (const chunk of api.llm.streamSpeech({
model: config.ttsConfig.model,
input: textContent,
voice: config.ttsConfig.voice,
speed: config.ttsConfig.speed,
})) {
for await (const chunk of api.llm.streamSpeech(
{
model: config.ttsConfig.model,
input: textContent,
voice: config.ttsConfig.voice,
speed: config.ttsConfig.speed,
},
ttsPlayer,
)) {
ttsPlayer.addToQueue(chunk);
}
ttsPlayer.finishStreamPlay();