同时播放聊条音频的问题修复

This commit is contained in:
francis_fh
2026-01-24 17:57:25 +08:00
parent cbf8bd7c41
commit 7a7aa33128
2 changed files with 400 additions and 365 deletions

View File

@@ -794,29 +794,10 @@ function readMarkdown(value, index) {
clearTimeout(ttsDebounceTimer);
}
// 如果当前正在播放其他消息,先停止
if (speechIndex.value !== index && speechIndex.value !== 0) {
console.log('🛑 Stopping current speech and starting new one');
speechIndex.value = index;
speak(value);
return;
}
// 总是先停止当前播放,无论是不是同一消息
console.log('🛑 Always stopping current speech before starting new one');
speechIndex.value = index;
// 如果当前正在播放且暂停了,直接恢复
if (isPaused.value && isSpeaking.value) {
console.log('▶️ Resuming paused speech');
resume();
return;
}
// 如果当前正在播放且没有暂停,不需要重新开始
if (isSpeaking.value && !isPaused.value) {
console.log('🔊 Already speaking, no need to restart');
return;
}
// 使用防抖避免频繁调用TTS
ttsDebounceTimer = setTimeout(() => {
console.log('🎵 Starting new speech');