@codingame/monaco-vscode-speech-service-override 5.2.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-speech-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@6.0.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/speech.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
2
2
|
import { ISpeechService } from 'vscode/vscode/vs/workbench/contrib/speech/common/speechService.service';
|
|
3
3
|
import { SpeechService } from './vscode/src/vs/workbench/contrib/speech/browser/speechService.js';
|
|
4
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
4
5
|
|
|
5
6
|
function getServiceOverride() {
|
|
6
7
|
return {
|
|
@@ -8,7 +8,7 @@ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/
|
|
|
8
8
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
9
9
|
import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host.service';
|
|
10
10
|
import { DeferredPromise } from 'vscode/vscode/vs/base/common/async';
|
|
11
|
-
import { HasSpeechProvider, SpeechToTextInProgress, speechLanguageConfigToLanguage, SPEECH_LANGUAGE_CONFIG, SpeechToTextStatus, KeywordRecognitionStatus } from 'vscode/vscode/vs/workbench/contrib/speech/common/speechService';
|
|
11
|
+
import { HasSpeechProvider, SpeechToTextInProgress, TextToSpeechInProgress, speechLanguageConfigToLanguage, SPEECH_LANGUAGE_CONFIG, SpeechToTextStatus, TextToSpeechStatus, KeywordRecognitionStatus } from 'vscode/vscode/vs/workbench/contrib/speech/common/speechService';
|
|
12
12
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
13
13
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
14
14
|
import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
|
|
@@ -57,13 +57,19 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
57
57
|
this.onDidStartSpeechToTextSession = this._onDidStartSpeechToTextSession.event;
|
|
58
58
|
this._onDidEndSpeechToTextSession = this._register(( (new Emitter())));
|
|
59
59
|
this.onDidEndSpeechToTextSession = this._onDidEndSpeechToTextSession.event;
|
|
60
|
-
this.
|
|
60
|
+
this.activeSpeechToTextSessions = 0;
|
|
61
61
|
this.speechToTextInProgress = SpeechToTextInProgress.bindTo(this.contextKeyService);
|
|
62
|
+
this._onDidStartTextToSpeechSession = this._register(( (new Emitter())));
|
|
63
|
+
this.onDidStartTextToSpeechSession = this._onDidStartTextToSpeechSession.event;
|
|
64
|
+
this._onDidEndTextToSpeechSession = this._register(( (new Emitter())));
|
|
65
|
+
this.onDidEndTextToSpeechSession = this._onDidEndTextToSpeechSession.event;
|
|
66
|
+
this.activeTextToSpeechSessions = 0;
|
|
67
|
+
this.textToSpeechInProgress = TextToSpeechInProgress.bindTo(this.contextKeyService);
|
|
62
68
|
this._onDidStartKeywordRecognition = this._register(( (new Emitter())));
|
|
63
69
|
this.onDidStartKeywordRecognition = this._onDidStartKeywordRecognition.event;
|
|
64
70
|
this._onDidEndKeywordRecognition = this._register(( (new Emitter())));
|
|
65
71
|
this.onDidEndKeywordRecognition = this._onDidEndKeywordRecognition.event;
|
|
66
|
-
this.
|
|
72
|
+
this.activeKeywordRecognitionSessions = 0;
|
|
67
73
|
this.handleAndRegisterSpeechExtensions();
|
|
68
74
|
}
|
|
69
75
|
handleAndRegisterSpeechExtensions() {
|
|
@@ -105,30 +111,30 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
105
111
|
this.hasSpeechProviderContext.set(this.hasSpeechProvider);
|
|
106
112
|
this._onDidChangeHasSpeechProvider.fire();
|
|
107
113
|
}
|
|
108
|
-
get hasActiveSpeechToTextSession() { return
|
|
114
|
+
get hasActiveSpeechToTextSession() { return this.activeSpeechToTextSessions > 0; }
|
|
109
115
|
async createSpeechToTextSession(token, context = 'speech') {
|
|
110
116
|
const provider = await this.getProvider();
|
|
111
117
|
const language = speechLanguageConfigToLanguage(this.configurationService.getValue(SPEECH_LANGUAGE_CONFIG));
|
|
112
|
-
const session =
|
|
118
|
+
const session = provider.createSpeechToTextSession(token, typeof language === 'string' ? { language } : undefined);
|
|
113
119
|
const sessionStart = Date.now();
|
|
114
120
|
let sessionRecognized = false;
|
|
115
121
|
let sessionError = false;
|
|
116
122
|
let sessionContentLength = 0;
|
|
117
123
|
const disposables = ( (new DisposableStore()));
|
|
118
124
|
const onSessionStoppedOrCanceled = () => {
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
this.activeSpeechToTextSessions = Math.max(0, this.activeSpeechToTextSessions - 1);
|
|
126
|
+
if (!this.hasActiveSpeechToTextSession) {
|
|
121
127
|
this.speechToTextInProgress.reset();
|
|
122
|
-
this._onDidEndSpeechToTextSession.fire();
|
|
123
|
-
this.telemetryService.publicLog2('speechToTextSession', {
|
|
124
|
-
context,
|
|
125
|
-
sessionDuration: Date.now() - sessionStart,
|
|
126
|
-
sessionRecognized,
|
|
127
|
-
sessionError,
|
|
128
|
-
sessionContentLength,
|
|
129
|
-
sessionLanguage: language
|
|
130
|
-
});
|
|
131
128
|
}
|
|
129
|
+
this._onDidEndSpeechToTextSession.fire();
|
|
130
|
+
this.telemetryService.publicLog2('speechToTextSession', {
|
|
131
|
+
context,
|
|
132
|
+
sessionDuration: Date.now() - sessionStart,
|
|
133
|
+
sessionRecognized,
|
|
134
|
+
sessionError,
|
|
135
|
+
sessionContentLength,
|
|
136
|
+
sessionLanguage: language
|
|
137
|
+
});
|
|
132
138
|
disposables.dispose();
|
|
133
139
|
};
|
|
134
140
|
disposables.add(token.onCancellationRequested(() => onSessionStoppedOrCanceled()));
|
|
@@ -138,10 +144,9 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
138
144
|
disposables.add(session.onDidChange(e => {
|
|
139
145
|
switch (e.status) {
|
|
140
146
|
case SpeechToTextStatus.Started:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
147
|
+
this.activeSpeechToTextSessions++;
|
|
148
|
+
this.speechToTextInProgress.set(true);
|
|
149
|
+
this._onDidStartSpeechToTextSession.fire();
|
|
145
150
|
break;
|
|
146
151
|
case SpeechToTextStatus.Recognizing:
|
|
147
152
|
sessionRecognized = true;
|
|
@@ -173,10 +178,55 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
173
178
|
}
|
|
174
179
|
return provider;
|
|
175
180
|
}
|
|
176
|
-
get
|
|
181
|
+
get hasActiveTextToSpeechSession() { return this.activeTextToSpeechSessions > 0; }
|
|
182
|
+
async createTextToSpeechSession(token, context = 'speech') {
|
|
183
|
+
const provider = await this.getProvider();
|
|
184
|
+
const language = speechLanguageConfigToLanguage(this.configurationService.getValue(SPEECH_LANGUAGE_CONFIG));
|
|
185
|
+
const session = provider.createTextToSpeechSession(token, typeof language === 'string' ? { language } : undefined);
|
|
186
|
+
const sessionStart = Date.now();
|
|
187
|
+
let sessionError = false;
|
|
188
|
+
const disposables = ( (new DisposableStore()));
|
|
189
|
+
const onSessionStoppedOrCanceled = (dispose) => {
|
|
190
|
+
this.activeTextToSpeechSessions = Math.max(0, this.activeTextToSpeechSessions - 1);
|
|
191
|
+
if (!this.hasActiveTextToSpeechSession) {
|
|
192
|
+
this.textToSpeechInProgress.reset();
|
|
193
|
+
}
|
|
194
|
+
this._onDidEndTextToSpeechSession.fire();
|
|
195
|
+
this.telemetryService.publicLog2('textToSpeechSession', {
|
|
196
|
+
context,
|
|
197
|
+
sessionDuration: Date.now() - sessionStart,
|
|
198
|
+
sessionError,
|
|
199
|
+
sessionLanguage: language
|
|
200
|
+
});
|
|
201
|
+
if (dispose) {
|
|
202
|
+
disposables.dispose();
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
disposables.add(token.onCancellationRequested(() => onSessionStoppedOrCanceled(true)));
|
|
206
|
+
if (token.isCancellationRequested) {
|
|
207
|
+
onSessionStoppedOrCanceled(true);
|
|
208
|
+
}
|
|
209
|
+
disposables.add(session.onDidChange(e => {
|
|
210
|
+
switch (e.status) {
|
|
211
|
+
case TextToSpeechStatus.Started:
|
|
212
|
+
this.activeTextToSpeechSessions++;
|
|
213
|
+
this.textToSpeechInProgress.set(true);
|
|
214
|
+
this._onDidStartTextToSpeechSession.fire();
|
|
215
|
+
break;
|
|
216
|
+
case TextToSpeechStatus.Stopped:
|
|
217
|
+
onSessionStoppedOrCanceled(false);
|
|
218
|
+
break;
|
|
219
|
+
case TextToSpeechStatus.Error:
|
|
220
|
+
this.logService.error(`Speech provider error in text to speech session: ${e.text}`);
|
|
221
|
+
sessionError = true;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}));
|
|
225
|
+
return session;
|
|
226
|
+
}
|
|
227
|
+
get hasActiveKeywordRecognition() { return this.activeKeywordRecognitionSessions > 0; }
|
|
177
228
|
async recognizeKeyword(token) {
|
|
178
229
|
const result = ( (new DeferredPromise()));
|
|
179
|
-
await this.extensionService.activateByEvent('onSpeech');
|
|
180
230
|
const disposables = ( (new DisposableStore()));
|
|
181
231
|
disposables.add(token.onCancellationRequested(() => {
|
|
182
232
|
disposables.dispose();
|
|
@@ -224,14 +274,13 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
224
274
|
}
|
|
225
275
|
async doRecognizeKeyword(token) {
|
|
226
276
|
const provider = await this.getProvider();
|
|
227
|
-
const session =
|
|
277
|
+
const session = provider.createKeywordRecognitionSession(token);
|
|
278
|
+
this.activeKeywordRecognitionSessions++;
|
|
228
279
|
this._onDidStartKeywordRecognition.fire();
|
|
229
280
|
const disposables = ( (new DisposableStore()));
|
|
230
281
|
const onSessionStoppedOrCanceled = () => {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
this._onDidEndKeywordRecognition.fire();
|
|
234
|
-
}
|
|
282
|
+
this.activeKeywordRecognitionSessions = Math.max(0, this.activeKeywordRecognitionSessions - 1);
|
|
283
|
+
this._onDidEndKeywordRecognition.fire();
|
|
235
284
|
disposables.dispose();
|
|
236
285
|
};
|
|
237
286
|
disposables.add(token.onCancellationRequested(() => onSessionStoppedOrCanceled()));
|