This commit is contained in:
meganrogge 2024-01-24 09:53:41 -08:00
parent 09231caec0
commit 8e5d9da1e4
No known key found for this signature in database
GPG key ID: AA74638D4878183D

View file

@ -16,6 +16,7 @@ import { ILogService } from 'vs/platform/log/common/log';
export const ISpeechService = createDecorator<ISpeechService>('speechService');
export const HasSpeechProvider = new RawContextKey<boolean>('hasSpeechProvider', false, { type: 'string', description: localize('hasSpeechProvider', "A speech provider is registered to the speech service.") });
export const SpeechInProgress = new RawContextKey<boolean>('speechInProgress', false, { type: 'string', description: localize('speechInProgress', "A speech session is in progress.") });
export interface ISpeechProviderMetadata {
readonly extension: ExtensionIdentifier;
@ -109,12 +110,21 @@ export class SpeechService extends Disposable implements ISpeechService {
private readonly providers = new Map<string, ISpeechProvider>();
private readonly hasSpeechProviderContext = HasSpeechProvider.bindTo(this.contextKeyService);
private readonly speechInProgress = SpeechInProgress.bindTo(this.contextKeyService);
private readonly _onDidStartSpeechToTextSession = this._register(new Emitter<void>());
readonly onDidStartSpeechToTextSession = this._onDidStartSpeechToTextSession.event;
private readonly _onDidEndSpeechToTextSession = this._register(new Emitter<void>());
readonly onDidEndSpeechToTextSession = this._onDidEndSpeechToTextSession.event;
constructor(
@ILogService private readonly logService: ILogService,
@IContextKeyService private readonly contextKeyService: IContextKeyService
) {
super();
this._register(this.onDidStartSpeechToTextSession(() => this.speechInProgress.set(true)));
this._register(this.onDidEndSpeechToTextSession(() => this.speechInProgress.reset()));
}
registerSpeechProvider(identifier: string, provider: ISpeechProvider): IDisposable {
@ -137,11 +147,6 @@ export class SpeechService extends Disposable implements ISpeechService {
});
}
private readonly _onDidStartSpeechToTextSession = this._register(new Emitter<void>());
readonly onDidStartSpeechToTextSession = this._onDidStartSpeechToTextSession.event;
private readonly _onDidEndSpeechToTextSession = this._register(new Emitter<void>());
readonly onDidEndSpeechToTextSession = this._onDidEndSpeechToTextSession.event;
private _activeSpeechToTextSession: ISpeechToTextSession | undefined = undefined;
get hasActiveSpeechToTextSession() { return !!this._activeSpeechToTextSession; }