@@ -16,7 +16,7 @@ import { ILogService } from 'vs/platform/log/common/log';
16
16
export const ISpeechService = createDecorator < ISpeechService > ( 'speechService' ) ;
17
17
18
18
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." ) } ) ;
20
20
21
21
export interface ISpeechProviderMetadata {
22
22
readonly extension : ExtensionIdentifier ;
@@ -110,21 +110,12 @@ export class SpeechService extends Disposable implements ISpeechService {
110
110
private readonly providers = new Map < string , ISpeechProvider > ( ) ;
111
111
112
112
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 ;
120
113
121
114
constructor (
122
115
@ILogService private readonly logService : ILogService ,
123
116
@IContextKeyService private readonly contextKeyService : IContextKeyService
124
117
) {
125
118
super ( ) ;
126
- this . _register ( this . onDidStartSpeechToTextSession ( ( ) => this . speechInProgress . set ( true ) ) ) ;
127
- this . _register ( this . onDidEndSpeechToTextSession ( ( ) => this . speechInProgress . reset ( ) ) ) ;
128
119
}
129
120
130
121
registerSpeechProvider ( identifier : string , provider : ISpeechProvider ) : IDisposable {
@@ -147,10 +138,17 @@ export class SpeechService extends Disposable implements ISpeechService {
147
138
} ) ;
148
139
}
149
140
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 ;
150
146
151
147
private _activeSpeechToTextSession : ISpeechToTextSession | undefined = undefined ;
152
148
get hasActiveSpeechToTextSession ( ) { return ! ! this . _activeSpeechToTextSession ; }
153
149
150
+ private readonly speechToTextInProgress = SpeechToTextInProgress . bindTo ( this . contextKeyService ) ;
151
+
154
152
createSpeechToTextSession ( token : CancellationToken ) : ISpeechToTextSession {
155
153
const provider = firstOrDefault ( Array . from ( this . providers . values ( ) ) ) ;
156
154
if ( ! provider ) {
@@ -166,6 +164,7 @@ export class SpeechService extends Disposable implements ISpeechService {
166
164
const onSessionStoppedOrCanceled = ( ) => {
167
165
if ( session === this . _activeSpeechToTextSession ) {
168
166
this . _activeSpeechToTextSession = undefined ;
167
+ this . speechToTextInProgress . reset ( ) ;
169
168
this . _onDidEndSpeechToTextSession . fire ( ) ;
170
169
}
171
170
@@ -181,6 +180,7 @@ export class SpeechService extends Disposable implements ISpeechService {
181
180
switch ( e . status ) {
182
181
case SpeechToTextStatus . Started :
183
182
if ( session === this . _activeSpeechToTextSession ) {
183
+ this . speechToTextInProgress . set ( true ) ;
184
184
this . _onDidStartSpeechToTextSession . fire ( ) ;
185
185
}
186
186
break ;
0 commit comments