Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"Bash(findstr:*)",
"Bash(npx prettier:*)",
"Bash(cd:*)",
"Bash(npm install:*)"
"Bash(npm install:*)",
"Bash(cat)",
"Read(//tmp/**)",
"Bash(xargs grep:*)"
]
}
}
118 changes: 57 additions & 61 deletions miniprogram/packageB/pages/chat-room/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,76 +865,72 @@ Page<IChatRoomPageData, IChatRoomCustomOption>({

// 强制停止语音识别,并在 ASR 完成后发送控制消息并显示切换提示(确保录音结果先到后端)
if (this.asrManager && wasRecording) {
// 强制停止语音识别,并在 ASR 完成后发送控制消息并显示切换提示(确保录音结果先到后端)
if (this.asrManager && wasRecording) {
if (canSpeak) {
this.stopAsrAndDefer('sendTurnEndAndNotify');
} else {
this.asrManager.stop();
}
} else if (canSpeak) {
// 未在录音,直接发送
this.sendSpeechTurnEnd();
if (canSpeak) {
this.stopAsrAndDefer('sendTurnEndAndNotify');
} else {
this.asrManager.stop();
}
} else if (canSpeak) {
// 未在录音,直接发送
this.sendSpeechTurnEnd();
}

const nextPhase: EPhase = PHASE_TRANSITION[phase];

if (nextPhase === EPhase.Done) {
// 清理定时器
if (this.timerId) {
clearInterval(this.timerId);
this.timerId = null;
}
const nextPhase: EPhase = PHASE_TRANSITION[phase];

this.stopListenerHintRotation();
if (nextPhase === EPhase.Done) {
// 清理定时器
if (this.timerId) {
clearInterval(this.timerId);
this.timerId = null;
}

this.setData({
phase: EPhase.Done,
canSpeak: false,
remaining: 0,
isRecording: false,
[liveKey]: '', // 仅清 live,final 保留
});
// 等待 CHAT_COMPLETE 消息触发跳转
} else {
const phaseApp = getApp<IAppOption>();
// 第二发言人是非第一发言人的那一方
this.currentSpeakerUserId = this.isSelfFirstSpeaker
? phaseApp.globalData.opponentUserId
: phaseApp.globalData.selfUserId;
const nextCanSpeak: boolean =
this.currentSpeakerUserId ===
phaseApp.globalData.selfUserId;

// 不再发言时停止倒计时(由新发言者自行启动)
if (!nextCanSpeak && this.timerId) {
clearInterval(this.timerId);
this.timerId = null;
}
this.stopListenerHintRotation();

// 显示"下一位"切换提示(录音中则等 OnRecognitionComplete 确认最后一段文本已发出)
if (!(this.asrManager && wasRecording)) {
void this.showSwitchNotification();
}
this.setData({
phase: EPhase.Done,
canSpeak: false,
remaining: 0,
isRecording: false,
[liveKey]: '', // 仅清 live,final 保留
});
// 等待 CHAT_COMPLETE 消息触发跳转
} else {
const phaseApp = getApp<IAppOption>();
// 第二发言人是非第一发言人的那一方
this.currentSpeakerUserId = this.isSelfFirstSpeaker
? phaseApp.globalData.opponentUserId
: phaseApp.globalData.selfUserId;
const nextCanSpeak: boolean =
this.currentSpeakerUserId === phaseApp.globalData.selfUserId;

// 不再发言时停止倒计时(由新发言者自行启动)
if (!nextCanSpeak && this.timerId) {
clearInterval(this.timerId);
this.timerId = null;
}

this.setData({
phase: nextPhase,
remaining: totalPerTurn,
canSpeak: nextCanSpeak,
countdownClass: this.getCountdownClass(totalPerTurn),
isRecording: false,
[liveKey]: '', // 仅清结束阶段的 live
listenerHint: nextCanSpeak ? '' : this.pickListenerHint(),
});
// 显示"下一位"切换提示(录音中则等 OnRecognitionComplete 确认最后一段文本已发出)
if (!(this.asrManager && wasRecording)) {
void this.showSwitchNotification();
}

if (nextCanSpeak) {
this.stopListenerHintRotation();
} else {
this.startListenerHintRotation();
}
this.setData({
phase: nextPhase,
remaining: totalPerTurn,
canSpeak: nextCanSpeak,
countdownClass: this.getCountdownClass(totalPerTurn),
isRecording: false,
[liveKey]: '', // 仅清结束阶段的 live
listenerHint: nextCanSpeak ? '' : this.pickListenerHint(),
});

asrService.resetSequence();
if (nextCanSpeak) {
this.stopListenerHintRotation();
} else {
this.startListenerHintRotation();
}

asrService.resetSequence();
}
},

Expand Down
Loading