Skip to content

Commit 1a94d0d

Browse files
authored
Merge pull request microsoft#203361 from microsoft/merogge/kb
add `speechInProgress` context key for keybinding reuse
2 parents 8494a40 + c4ea2a8 commit 1a94d0d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/vs/workbench/contrib/speech/common/speechService.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ILogService } from 'vs/platform/log/common/log';
1616
export const ISpeechService = createDecorator<ISpeechService>('speechService');
1717

1818
export const HasSpeechProvider = new RawContextKey<boolean>('hasSpeechProvider', false, { type: 'string', description: localize('hasSpeechProvider', "A speech provider is registered to the speech service.") });
19+
export const SpeechToTextInProgress = new RawContextKey<boolean>('speechToTextInProgress', false, { type: 'string', description: localize('speechToTextInProgress', "A speech-to-text session is in progress.") });
1920

2021
export interface ISpeechProviderMetadata {
2122
readonly extension: ExtensionIdentifier;
@@ -146,6 +147,8 @@ export class SpeechService extends Disposable implements ISpeechService {
146147
private _activeSpeechToTextSession: ISpeechToTextSession | undefined = undefined;
147148
get hasActiveSpeechToTextSession() { return !!this._activeSpeechToTextSession; }
148149

150+
private readonly speechToTextInProgress = SpeechToTextInProgress.bindTo(this.contextKeyService);
151+
149152
createSpeechToTextSession(token: CancellationToken): ISpeechToTextSession {
150153
const provider = firstOrDefault(Array.from(this.providers.values()));
151154
if (!provider) {
@@ -161,6 +164,7 @@ export class SpeechService extends Disposable implements ISpeechService {
161164
const onSessionStoppedOrCanceled = () => {
162165
if (session === this._activeSpeechToTextSession) {
163166
this._activeSpeechToTextSession = undefined;
167+
this.speechToTextInProgress.reset();
164168
this._onDidEndSpeechToTextSession.fire();
165169
}
166170

@@ -176,6 +180,7 @@ export class SpeechService extends Disposable implements ISpeechService {
176180
switch (e.status) {
177181
case SpeechToTextStatus.Started:
178182
if (session === this._activeSpeechToTextSession) {
183+
this.speechToTextInProgress.set(true);
179184
this._onDidStartSpeechToTextSession.fire();
180185
}
181186
break;

0 commit comments

Comments
 (0)