Skip to content

Commit b0d1f89

Browse files
authored
speech recording stops after log pause in audio (fix microsoft#203189) (microsoft#203433)
1 parent a908e9d commit b0d1f89

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ import { IChatWidget, IChatWidgetService } from 'vs/workbench/contrib/chat/brows
1212
import { CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_CHAT_REQUEST_IN_PROGRESS } from 'vs/workbench/contrib/chat/common/chatContextKeys';
1313
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
1414

15+
export interface IVoiceChatExecuteActionContext {
16+
readonly disableTimeout?: boolean;
17+
}
18+
1519
export interface IChatExecuteActionContext {
1620
widget?: IChatWidget;
1721
inputValue?: string;
22+
voice?: IVoiceChatExecuteActionContext;
1823
}
1924

2025
export class SubmitAction extends Action2 {

src/vs/workbench/contrib/chat/electron-sandbox/actions/voiceChatActions.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class VoiceChatSessions {
262262
@IConfigurationService private readonly configurationService: IConfigurationService
263263
) { }
264264

265-
async start(controller: IVoiceChatSessionController): Promise<void> {
265+
async start(controller: IVoiceChatSessionController, context?: IChatExecuteActionContext): Promise<void> {
266266
this.stop();
267267

268268
const sessionId = ++this.voiceChatSessionIds;
@@ -304,7 +304,7 @@ class VoiceChatSessions {
304304
case SpeechToTextStatus.Recognizing:
305305
if (text) {
306306
session.controller.updateInput([inputValue, text].join(' '));
307-
if (voiceChatTimeout > 0) {
307+
if (voiceChatTimeout > 0 && context?.voice?.disableTimeout !== true) {
308308
acceptTranscriptionScheduler.cancel();
309309
}
310310
}
@@ -313,7 +313,7 @@ class VoiceChatSessions {
313313
if (text) {
314314
inputValue = [inputValue, text].join(' ');
315315
session.controller.updateInput(inputValue);
316-
if (voiceChatTimeout > 0) {
316+
if (voiceChatTimeout > 0 && context?.voice?.disableTimeout !== true) {
317317
acceptTranscriptionScheduler.schedule();
318318
}
319319
}
@@ -408,12 +408,12 @@ export class VoiceChatInChatViewAction extends Action2 {
408408
});
409409
}
410410

411-
async run(accessor: ServicesAccessor): Promise<void> {
411+
async run(accessor: ServicesAccessor, context?: IChatExecuteActionContext): Promise<void> {
412412
const instantiationService = accessor.get(IInstantiationService);
413413

414414
const controller = await VoiceChatSessionControllerFactory.create(accessor, 'view');
415415
if (controller) {
416-
VoiceChatSessions.getInstance(instantiationService).start(controller);
416+
VoiceChatSessions.getInstance(instantiationService).start(controller, context);
417417
}
418418
}
419419
}
@@ -435,12 +435,12 @@ export class InlineVoiceChatAction extends Action2 {
435435
});
436436
}
437437

438-
async run(accessor: ServicesAccessor): Promise<void> {
438+
async run(accessor: ServicesAccessor, context?: IChatExecuteActionContext): Promise<void> {
439439
const instantiationService = accessor.get(IInstantiationService);
440440

441441
const controller = await VoiceChatSessionControllerFactory.create(accessor, 'inline');
442442
if (controller) {
443-
VoiceChatSessions.getInstance(instantiationService).start(controller);
443+
VoiceChatSessions.getInstance(instantiationService).start(controller, context);
444444
}
445445
}
446446
}
@@ -462,12 +462,12 @@ export class QuickVoiceChatAction extends Action2 {
462462
});
463463
}
464464

465-
async run(accessor: ServicesAccessor): Promise<void> {
465+
async run(accessor: ServicesAccessor, context?: IChatExecuteActionContext): Promise<void> {
466466
const instantiationService = accessor.get(IInstantiationService);
467467

468468
const controller = await VoiceChatSessionControllerFactory.create(accessor, 'quick');
469469
if (controller) {
470-
VoiceChatSessions.getInstance(instantiationService).start(controller);
470+
VoiceChatSessions.getInstance(instantiationService).start(controller, context);
471471
}
472472
}
473473
}
@@ -500,11 +500,11 @@ export class StartVoiceChatAction extends Action2 {
500500
});
501501
}
502502

503-
async run(accessor: ServicesAccessor, context: unknown): Promise<void> {
503+
async run(accessor: ServicesAccessor, context?: IChatExecuteActionContext): Promise<void> {
504504
const instantiationService = accessor.get(IInstantiationService);
505505
const commandService = accessor.get(ICommandService);
506506

507-
const widget = (context as IChatExecuteActionContext)?.widget;
507+
const widget = context?.widget;
508508
if (widget) {
509509
// if we already get a context when the action is executed
510510
// from a toolbar within the chat widget, then make sure
@@ -518,10 +518,10 @@ export class StartVoiceChatAction extends Action2 {
518518

519519
const controller = await VoiceChatSessionControllerFactory.create(accessor, 'focused');
520520
if (controller) {
521-
VoiceChatSessions.getInstance(instantiationService).start(controller);
521+
VoiceChatSessions.getInstance(instantiationService).start(controller, context);
522522
} else {
523523
// fallback to Quick Voice Chat command
524-
commandService.executeCommand(QuickVoiceChatAction.ID);
524+
commandService.executeCommand(QuickVoiceChatAction.ID, context);
525525
}
526526
}
527527
}

src/vs/workbench/contrib/inlineChat/electron-sandbox/inlineChatActions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
1616
import { ICommandService } from 'vs/platform/commands/common/commands';
1717
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1818
import { StartVoiceChatAction, StopListeningAction } from 'vs/workbench/contrib/chat/electron-sandbox/actions/voiceChatActions';
19+
import { IChatExecuteActionContext } from 'vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
1920
import { CTX_INLINE_CHAT_HAS_PROVIDER, CTX_INLINE_CHAT_VISIBLE, InlineChatConfigKeys } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
2021
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2122
import { HasSpeechProvider, ISpeechService } from 'vs/workbench/contrib/speech/common/speechService';
@@ -95,7 +96,7 @@ function holdForSpeech(accessor: ServicesAccessor, ctrl: InlineChatController |
9596
let listening = false;
9697
const handle = disposableTimeout(() => {
9798
// start VOICE input
98-
commandService.executeCommand(StartVoiceChatAction.ID);
99+
commandService.executeCommand(StartVoiceChatAction.ID, { voice: { disableTimeout: true } } satisfies IChatExecuteActionContext);
99100
listening = true;
100101
}, 250);
101102

0 commit comments

Comments
 (0)