Merge pull request 'fix: 修复 deploy 工作流缺少 Node.js 导致 checkout 失败的问题' #72
@@ -158,6 +158,10 @@ export function useVisionSession() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 停止上一轮的 TTS 播放,防止新旧音频重叠
|
||||||
|
ttsPlayerRef.current?.stop();
|
||||||
|
setIsAudioPlaying(false);
|
||||||
|
|
||||||
const frame = captureFrame();
|
const frame = captureFrame();
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
console.warn("[Session] 无法捕获图像帧");
|
console.warn("[Session] 无法捕获图像帧");
|
||||||
|
|||||||
@@ -47,6 +47,19 @@ export class TTSPlayer {
|
|||||||
this._isPlaying = false;
|
this._isPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止当前正在播放的音频(不清空 chunks)
|
||||||
|
* 用于 play() 开始前,防止新旧音频重叠
|
||||||
|
*/
|
||||||
|
private stopCurrentAudio(): void {
|
||||||
|
if (this.audio) {
|
||||||
|
this.audio.pause();
|
||||||
|
this.audio.removeAttribute("src");
|
||||||
|
this.audio = null;
|
||||||
|
}
|
||||||
|
this._isPlaying = false;
|
||||||
|
}
|
||||||
|
|
||||||
/** 暂停播放 */
|
/** 暂停播放 */
|
||||||
pause(): void {
|
pause(): void {
|
||||||
this.audio?.pause();
|
this.audio?.pause();
|
||||||
@@ -61,6 +74,9 @@ export class TTSPlayer {
|
|||||||
private play(mimeType: string): void {
|
private play(mimeType: string): void {
|
||||||
if (this.chunks.length === 0) return;
|
if (this.chunks.length === 0) return;
|
||||||
|
|
||||||
|
// 停止当前正在播放的音频,防止重叠
|
||||||
|
this.stopCurrentAudio();
|
||||||
|
|
||||||
// 拼接所有 Base64 片段
|
// 拼接所有 Base64 片段
|
||||||
const combined = this.chunks.join("");
|
const combined = this.chunks.join("");
|
||||||
this.chunks = [];
|
this.chunks = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user