Skip to content

Commit c4ea2a8

Browse files
committed
💄
1 parent cc5dd53 commit c4ea2a8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +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.") });
19+
export const SpeechToTextInProgress = new RawContextKey<boolean>('speechToTextInProgress', false, { type: 'string', description: localize('speechToTextInProgress', "A speech-to-text session is in progress.") });
2020

2121
export interface ISpeechProviderMetadata {
2222
readonly extension: ExtensionIdentifier;
@@ -110,21 +110,12 @@ export class SpeechService extends Disposable implements ISpeechService {
110110
private readonly providers = new Map<string, ISpeechProvider>();
111111

112112
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;
120113

121114
constructor(
122115
@ILogService private readonly logService: ILogService,
123116
@IContextKeyService private readonly contextKeyService: IContextKeyService
124117
) {
125118
super();
126-
this._register(this.onDidStartSpeechToTextSession(() => this.speechInProgress.set(true)));
127-
this._register(this.onDidEndSpeechToTextSession(() => this.speechInProgress.reset()));
128119
}
129120

130121
registerSpeechProvider(identifier: string, provider: ISpeechProvider): IDisposable {
@@ -147,10 +138,17 @@ export class SpeechService extends Disposable implements ISpeechService {
147138
});
148139
}
149140

141+
private readonly _onDidStartSpeechToTextSession = this._register(new Emitter<void>());
142+
readonly onDidStartSpeechToTextSession = this._onDidStartSpeechToTextSession.event;
143+
144+
private readonly _onDidEndSpeechToTextSession = this._register(new Emitter<void>());
145+
readonly onDidEndSpeechToTextSession = this._onDidEndSpeechToTextSession.event;
150146

151147
private _activeSpeechToTextSession: ISpeechToTextSession | undefined = undefined;
152148
get hasActiveSpeechToTextSession() { return !!this._activeSpeechToTextSession; }
153149

150+
private readonly speechToTextInProgress = SpeechToTextInProgress.bindTo(this.contextKeyService);
151+
154152
createSpeechToTextSession(token: CancellationToken): ISpeechToTextSession {
155153
const provider = firstOrDefault(Array.from(this.providers.values()));
156154
if (!provider) {
@@ -166,6 +164,7 @@ export class SpeechService extends Disposable implements ISpeechService {
166164
const onSessionStoppedOrCanceled = () => {
167165
if (session === this._activeSpeechToTextSession) {
168166
this._activeSpeechToTextSession = undefined;
167+
this.speechToTextInProgress.reset();
169168
this._onDidEndSpeechToTextSession.fire();
170169
}
171170

@@ -181,6 +180,7 @@ export class SpeechService extends Disposable implements ISpeechService {
181180
switch (e.status) {
182181
case SpeechToTextStatus.Started:
183182
if (session === this._activeSpeechToTextSession) {
183+
this.speechToTextInProgress.set(true);
184184
this._onDidStartSpeechToTextSession.fire();
185185
}
186186
break;

0 commit comments

Comments
 (0)