Skip to content

Commit 8e5d9da

Browse files
committed
1 parent 09231ca commit 8e5d9da

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 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 SpeechInProgress = new RawContextKey<boolean>('speechInProgress', false, { type: 'string', description: localize('speechInProgress', "A speech session is in progress.") });
1920

2021
export interface ISpeechProviderMetadata {
2122
readonly extension: ExtensionIdentifier;
@@ -109,12 +110,21 @@ export class SpeechService extends Disposable implements ISpeechService {
109110
private readonly providers = new Map<string, ISpeechProvider>();
110111

111112
private readonly hasSpeechProviderContext = HasSpeechProvider.bindTo(this.contextKeyService);
113+
private readonly speechInProgress = SpeechInProgress.bindTo(this.contextKeyService);
114+
115+
private readonly _onDidStartSpeechToTextSession = this._register(new Emitter<void>());
116+
readonly onDidStartSpeechToTextSession = this._onDidStartSpeechToTextSession.event;
117+
118+
private readonly _onDidEndSpeechToTextSession = this._register(new Emitter<void>());
119+
readonly onDidEndSpeechToTextSession = this._onDidEndSpeechToTextSession.event;
112120

113121
constructor(
114122
@ILogService private readonly logService: ILogService,
115123
@IContextKeyService private readonly contextKeyService: IContextKeyService
116124
) {
117125
super();
126+
this._register(this.onDidStartSpeechToTextSession(() => this.speechInProgress.set(true)));
127+
this._register(this.onDidEndSpeechToTextSession(() => this.speechInProgress.reset()));
118128
}
119129

120130
registerSpeechProvider(identifier: string, provider: ISpeechProvider): IDisposable {
@@ -137,11 +147,6 @@ export class SpeechService extends Disposable implements ISpeechService {
137147
});
138148
}
139149

140-
private readonly _onDidStartSpeechToTextSession = this._register(new Emitter<void>());
141-
readonly onDidStartSpeechToTextSession = this._onDidStartSpeechToTextSession.event;
142-
143-
private readonly _onDidEndSpeechToTextSession = this._register(new Emitter<void>());
144-
readonly onDidEndSpeechToTextSession = this._onDidEndSpeechToTextSession.event;
145150

146151
private _activeSpeechToTextSession: ISpeechToTextSession | undefined = undefined;
147152
get hasActiveSpeechToTextSession() { return !!this._activeSpeechToTextSession; }

0 commit comments

Comments
 (0)