|
@@ -171,11 +171,25 @@ const playTTS = async (ttsMessage) => {
|
|
|
|
|
|
// 2. 播放下一个音频(修改后)
|
|
|
const playNextAudio = async () => {
|
|
|
- if (audioQueue.length === 0) {
|
|
|
+ // if (audioQueue.length === 0) {
|
|
|
+ // isPlaying = false;
|
|
|
+ // console.log("所有音频播放完毕.");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ if (audioQueue.length === 0 && playingQueue.length > 0) {
|
|
|
+ const maxPlayed = Math.max(...playingQueue);
|
|
|
+ if (orderId > maxPlayed + 1) {
|
|
|
+ console.log("仍有未完成请求,暂不重置");
|
|
|
+ } else {
|
|
|
isPlaying = false;
|
|
|
- console.log("所有音频播放完毕.");
|
|
|
+ // 新增:当队列完全播放完毕时重置所有状态
|
|
|
+ audioQueue = [];
|
|
|
+ playingQueue = [];
|
|
|
+ orderId = 0; // 可选:如果需要重置顺序号
|
|
|
+ console.log("所有音频播放完毕,已重置播放队列.");
|
|
|
return;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
const nextAudio = getNextAudioToPlay();
|
|
|
if (!nextAudio) {
|