feat(voice): 按住空格键语音输入(PTT),松开发送
按住空格键开始聆听,松开发送 end 指令提交任务。不销毁麦克风上下文, 下次重按直接复用,避免 getUserMedia/AudioContext 重建延迟。 支持输入框/文本区内不抢空格、窗口失焦自动取消。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -263,6 +263,14 @@ export class VoiceClient {
|
||||
if (this.state === "listening") this.setState("thinking");
|
||||
}
|
||||
|
||||
// stopPTT 结束本轮说话但保留麦克风上下文:用于按住空格(PTT)松开发送场景。
|
||||
// 不销毁 micNode/micStream,下次重按 startListening 时 startMic 直接早返回,
|
||||
// 避免 getUserMedia / AudioContext 重建延迟,实现快速重按。
|
||||
stopPTT(): void {
|
||||
this.send({ type: "end" });
|
||||
if (this.state === "listening") this.setState("thinking");
|
||||
}
|
||||
|
||||
// bargeIn 打断当前朗读(用户又开口)。
|
||||
bargeIn(): void {
|
||||
this.send({ type: "barge_in" });
|
||||
|
||||
Reference in New Issue
Block a user