@codingame/monaco-vscode-speech-service-override 25.1.2 → 26.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": "26.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - speech service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "26.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -15,31 +15,45 @@ import { ExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workb
|
|
|
15
15
|
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
16
16
|
|
|
17
17
|
const speechProvidersExtensionPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
18
|
-
extensionPoint:
|
|
18
|
+
extensionPoint: "speechProviders",
|
|
19
19
|
jsonSchema: {
|
|
20
|
-
description: ( localize(
|
|
21
|
-
type:
|
|
20
|
+
description: ( localize(11343, "Contributes a Speech Provider")),
|
|
21
|
+
type: "array",
|
|
22
22
|
items: {
|
|
23
23
|
additionalProperties: false,
|
|
24
|
-
type:
|
|
25
|
-
defaultSnippets: [{
|
|
26
|
-
|
|
24
|
+
type: "object",
|
|
25
|
+
defaultSnippets: [{
|
|
26
|
+
body: {
|
|
27
|
+
name: "",
|
|
28
|
+
description: ""
|
|
29
|
+
}
|
|
30
|
+
}],
|
|
31
|
+
required: ["name"],
|
|
27
32
|
properties: {
|
|
28
33
|
name: {
|
|
29
|
-
description: ( localize(
|
|
30
|
-
type:
|
|
34
|
+
description: ( localize(11344, "Unique name for this Speech Provider.")),
|
|
35
|
+
type: "string"
|
|
31
36
|
},
|
|
32
37
|
description: {
|
|
33
|
-
description: ( localize(
|
|
34
|
-
type:
|
|
38
|
+
description: ( localize(11345, "A description of this Speech Provider, shown in the UI.")),
|
|
39
|
+
type: "string"
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
});
|
|
40
45
|
let SpeechService = class SpeechService extends Disposable {
|
|
41
|
-
get hasSpeechProvider() {
|
|
42
|
-
|
|
46
|
+
get hasSpeechProvider() {
|
|
47
|
+
return this.providerDescriptors.size > 0 || this.providers.size > 0;
|
|
48
|
+
}
|
|
49
|
+
constructor(
|
|
50
|
+
logService,
|
|
51
|
+
contextKeyService,
|
|
52
|
+
hostService,
|
|
53
|
+
telemetryService,
|
|
54
|
+
configurationService,
|
|
55
|
+
extensionService
|
|
56
|
+
) {
|
|
43
57
|
super();
|
|
44
58
|
this.logService = logService;
|
|
45
59
|
this.hostService = hostService;
|
|
@@ -109,11 +123,15 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
109
123
|
this.hasSpeechProviderContext.set(this.hasSpeechProvider);
|
|
110
124
|
this._onDidChangeHasSpeechProvider.fire();
|
|
111
125
|
}
|
|
112
|
-
get hasActiveSpeechToTextSession() {
|
|
113
|
-
|
|
126
|
+
get hasActiveSpeechToTextSession() {
|
|
127
|
+
return this.activeSpeechToTextSessions > 0;
|
|
128
|
+
}
|
|
129
|
+
async createSpeechToTextSession(token, context = "speech") {
|
|
114
130
|
const provider = await this.getProvider();
|
|
115
131
|
const language = speechLanguageConfigToLanguage(this.configurationService.getValue(SPEECH_LANGUAGE_CONFIG));
|
|
116
|
-
const session = provider.createSpeechToTextSession(token, typeof language ===
|
|
132
|
+
const session = provider.createSpeechToTextSession(token, typeof language === "string" ? {
|
|
133
|
+
language
|
|
134
|
+
} : undefined);
|
|
117
135
|
const sessionStart = Date.now();
|
|
118
136
|
let sessionRecognized = false;
|
|
119
137
|
let sessionError = false;
|
|
@@ -125,7 +143,7 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
125
143
|
this.speechToTextInProgress.reset();
|
|
126
144
|
}
|
|
127
145
|
this._onDidEndSpeechToTextSession.fire();
|
|
128
|
-
this.telemetryService.publicLog2(
|
|
146
|
+
this.telemetryService.publicLog2("speechToTextSession", {
|
|
129
147
|
context,
|
|
130
148
|
sessionDuration: Date.now() - sessionStart,
|
|
131
149
|
sessionRecognized,
|
|
@@ -141,56 +159,61 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
141
159
|
}
|
|
142
160
|
disposables.add(session.onDidChange(e => {
|
|
143
161
|
switch (e.status) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
case SpeechToTextStatus.Started:
|
|
163
|
+
this.activeSpeechToTextSessions++;
|
|
164
|
+
this.speechToTextInProgress.set(true);
|
|
165
|
+
this._onDidStartSpeechToTextSession.fire();
|
|
166
|
+
break;
|
|
167
|
+
case SpeechToTextStatus.Recognizing:
|
|
168
|
+
sessionRecognized = true;
|
|
169
|
+
break;
|
|
170
|
+
case SpeechToTextStatus.Recognized:
|
|
171
|
+
if (typeof e.text === "string") {
|
|
172
|
+
sessionContentLength += e.text.length;
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
case SpeechToTextStatus.Stopped:
|
|
176
|
+
onSessionStoppedOrCanceled();
|
|
177
|
+
break;
|
|
178
|
+
case SpeechToTextStatus.Error:
|
|
179
|
+
this.logService.error(`Speech provider error in speech to text session: ${e.text}`);
|
|
180
|
+
sessionError = true;
|
|
181
|
+
break;
|
|
164
182
|
}
|
|
165
183
|
}));
|
|
166
184
|
return session;
|
|
167
185
|
}
|
|
168
186
|
async getProvider() {
|
|
169
|
-
await this.extensionService.activateByEvent(
|
|
187
|
+
await this.extensionService.activateByEvent("onSpeech");
|
|
170
188
|
const provider = Array.from(( this.providers.values())).at(0);
|
|
171
189
|
if (!provider) {
|
|
172
190
|
throw ( new Error(`No Speech provider is registered.`));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
191
|
+
} else if (this.providers.size > 1) {
|
|
192
|
+
this.logService.warn(
|
|
193
|
+
`Multiple speech providers registered. Picking first one: ${provider.metadata.displayName}`
|
|
194
|
+
);
|
|
176
195
|
}
|
|
177
196
|
return provider;
|
|
178
197
|
}
|
|
179
|
-
get hasActiveTextToSpeechSession() {
|
|
180
|
-
|
|
198
|
+
get hasActiveTextToSpeechSession() {
|
|
199
|
+
return this.activeTextToSpeechSessions > 0;
|
|
200
|
+
}
|
|
201
|
+
async createTextToSpeechSession(token, context = "speech") {
|
|
181
202
|
const provider = await this.getProvider();
|
|
182
203
|
const language = speechLanguageConfigToLanguage(this.configurationService.getValue(SPEECH_LANGUAGE_CONFIG));
|
|
183
|
-
const session = provider.createTextToSpeechSession(token, typeof language ===
|
|
204
|
+
const session = provider.createTextToSpeechSession(token, typeof language === "string" ? {
|
|
205
|
+
language
|
|
206
|
+
} : undefined);
|
|
184
207
|
const sessionStart = Date.now();
|
|
185
208
|
let sessionError = false;
|
|
186
209
|
const disposables = ( new DisposableStore());
|
|
187
|
-
const onSessionStoppedOrCanceled =
|
|
210
|
+
const onSessionStoppedOrCanceled = dispose => {
|
|
188
211
|
this.activeTextToSpeechSessions = Math.max(0, this.activeTextToSpeechSessions - 1);
|
|
189
212
|
if (!this.hasActiveTextToSpeechSession) {
|
|
190
213
|
this.textToSpeechInProgress.reset();
|
|
191
214
|
}
|
|
192
215
|
this._onDidEndTextToSpeechSession.fire();
|
|
193
|
-
this.telemetryService.publicLog2(
|
|
216
|
+
this.telemetryService.publicLog2("textToSpeechSession", {
|
|
194
217
|
context,
|
|
195
218
|
sessionDuration: Date.now() - sessionStart,
|
|
196
219
|
sessionError,
|
|
@@ -206,23 +229,25 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
206
229
|
}
|
|
207
230
|
disposables.add(session.onDidChange(e => {
|
|
208
231
|
switch (e.status) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
232
|
+
case TextToSpeechStatus.Started:
|
|
233
|
+
this.activeTextToSpeechSessions++;
|
|
234
|
+
this.textToSpeechInProgress.set(true);
|
|
235
|
+
this._onDidStartTextToSpeechSession.fire();
|
|
236
|
+
break;
|
|
237
|
+
case TextToSpeechStatus.Stopped:
|
|
238
|
+
onSessionStoppedOrCanceled(false);
|
|
239
|
+
break;
|
|
240
|
+
case TextToSpeechStatus.Error:
|
|
241
|
+
this.logService.error(`Speech provider error in text to speech session: ${e.text}`);
|
|
242
|
+
sessionError = true;
|
|
243
|
+
break;
|
|
221
244
|
}
|
|
222
245
|
}));
|
|
223
246
|
return session;
|
|
224
247
|
}
|
|
225
|
-
get hasActiveKeywordRecognition() {
|
|
248
|
+
get hasActiveKeywordRecognition() {
|
|
249
|
+
return this.activeKeywordRecognitionSessions > 0;
|
|
250
|
+
}
|
|
226
251
|
async recognizeKeyword(token) {
|
|
227
252
|
const result = ( new DeferredPromise());
|
|
228
253
|
const disposables = ( new DisposableStore());
|
|
@@ -250,8 +275,7 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
250
275
|
if (!focused && activeRecognizeKeywordSession) {
|
|
251
276
|
recognizeKeywordDisposables.clear();
|
|
252
277
|
activeRecognizeKeywordSession = undefined;
|
|
253
|
-
}
|
|
254
|
-
else if (!activeRecognizeKeywordSession) {
|
|
278
|
+
} else if (!activeRecognizeKeywordSession) {
|
|
255
279
|
recognizeKeyword();
|
|
256
280
|
}
|
|
257
281
|
}));
|
|
@@ -261,11 +285,10 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
261
285
|
let status;
|
|
262
286
|
try {
|
|
263
287
|
status = await result.p;
|
|
264
|
-
}
|
|
265
|
-
finally {
|
|
288
|
+
} finally {
|
|
266
289
|
disposables.dispose();
|
|
267
290
|
}
|
|
268
|
-
this.telemetryService.publicLog2(
|
|
291
|
+
this.telemetryService.publicLog2("keywordRecognition", {
|
|
269
292
|
keywordRecognized: status === KeywordRecognitionStatus.Recognized
|
|
270
293
|
});
|
|
271
294
|
return status;
|
|
@@ -292,19 +315,11 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
292
315
|
}));
|
|
293
316
|
try {
|
|
294
317
|
return (await Event.toPromise(session.onDidChange)).status;
|
|
295
|
-
}
|
|
296
|
-
finally {
|
|
318
|
+
} finally {
|
|
297
319
|
onSessionStoppedOrCanceled();
|
|
298
320
|
}
|
|
299
321
|
}
|
|
300
322
|
};
|
|
301
|
-
SpeechService = ( __decorate([
|
|
302
|
-
( __param(0, ILogService)),
|
|
303
|
-
( __param(1, IContextKeyService)),
|
|
304
|
-
( __param(2, IHostService)),
|
|
305
|
-
( __param(3, ITelemetryService)),
|
|
306
|
-
( __param(4, IConfigurationService)),
|
|
307
|
-
( __param(5, IExtensionService))
|
|
308
|
-
], SpeechService));
|
|
323
|
+
SpeechService = ( __decorate([( __param(0, ILogService)), ( __param(1, IContextKeyService)), ( __param(2, IHostService)), ( __param(3, ITelemetryService)), ( __param(4, IConfigurationService)), ( __param(5, IExtensionService))], SpeechService));
|
|
309
324
|
|
|
310
325
|
export { SpeechService };
|