From 54ffc0e8a349da4ebbcfaa9c392cd5e3dd81fc4c Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 9 Feb 2024 10:06:02 +0100 Subject: [PATCH] . --- src/vs/workbench/contrib/chat/common/voiceChat.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/chat/common/voiceChat.ts b/src/vs/workbench/contrib/chat/common/voiceChat.ts index 93481ed63c3..cec3df65409 100644 --- a/src/vs/workbench/contrib/chat/common/voiceChat.ts +++ b/src/vs/workbench/contrib/chat/common/voiceChat.ts @@ -91,16 +91,21 @@ export class VoiceChatService extends Disposable implements IVoiceChatService { } createVoiceChatSession(token: CancellationToken): IVoiceChatSession { - const session = this.speechService.createSpeechToTextSession(token); - const disposables = new DisposableStore(); + let finishedPhraseDetection = false; + const emitter = disposables.add(new Emitter()); + const session = disposables.add(this.speechService.createSpeechToTextSession(token)); disposables.add(session.onDidChange(e => { switch (e.status) { case SpeechToTextStatus.Recognizing: case SpeechToTextStatus.Recognized: - if (e.text && startsWithIgnoreCase(e.text, VoiceChatService.PHRASES[VoiceChatService.AGENT_PREFIX].trim())) { + if ( + !finishedPhraseDetection && // only if we have not yet attempted phrase detection + e.text && + startsWithIgnoreCase(e.text, VoiceChatService.PHRASES[VoiceChatService.AGENT_PREFIX].trim()) + ) { const originalWords = e.text.split(' '); let transformedWords: string[] | undefined; @@ -114,6 +119,8 @@ export class VoiceChatService extends Disposable implements IVoiceChatService { waitingForInput = originalWords.length === 4; } + + finishedPhraseDetection = true; // only detect phrases in the beginning of the session } // Check for agent