@codingame/monaco-vscode-speech-service-override 4.5.1 → 5.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": "5.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@5.0.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -11,19 +11,14 @@ import { DeferredPromise } from 'vscode/vscode/vs/base/common/async';
|
|
|
11
11
|
import { HasSpeechProvider, SpeechToTextInProgress, speechLanguageConfigToLanguage, SPEECH_LANGUAGE_CONFIG, SpeechToTextStatus, 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
|
-
import { AccessibilitySignal } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
|
|
15
|
-
import { IAccessibilitySignalService } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
|
|
16
14
|
import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
|
|
17
15
|
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
18
16
|
|
|
17
|
+
const _moduleId = "vs/workbench/contrib/speech/browser/speechService";
|
|
19
18
|
const speechProvidersExtensionPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
20
19
|
extensionPoint: 'speechProviders',
|
|
21
20
|
jsonSchema: {
|
|
22
|
-
description: ( localizeWithPath(
|
|
23
|
-
'vs/workbench/contrib/speech/browser/speechService',
|
|
24
|
-
'vscode.extension.contributes.speechProvider',
|
|
25
|
-
'Contributes a Speech Provider'
|
|
26
|
-
)),
|
|
21
|
+
description: ( localizeWithPath(_moduleId, 0, 'Contributes a Speech Provider')),
|
|
27
22
|
type: 'array',
|
|
28
23
|
items: {
|
|
29
24
|
additionalProperties: false,
|
|
@@ -32,19 +27,11 @@ const speechProvidersExtensionPoint = ExtensionsRegistry.registerExtensionPoint(
|
|
|
32
27
|
required: ['name'],
|
|
33
28
|
properties: {
|
|
34
29
|
name: {
|
|
35
|
-
description: ( localizeWithPath(
|
|
36
|
-
'vs/workbench/contrib/speech/browser/speechService',
|
|
37
|
-
'speechProviderName',
|
|
38
|
-
"Unique name for this Speech Provider."
|
|
39
|
-
)),
|
|
30
|
+
description: ( localizeWithPath(_moduleId, 1, "Unique name for this Speech Provider.")),
|
|
40
31
|
type: 'string'
|
|
41
32
|
},
|
|
42
33
|
description: {
|
|
43
|
-
description: ( localizeWithPath(
|
|
44
|
-
'vs/workbench/contrib/speech/browser/speechService',
|
|
45
|
-
'speechProviderDescription',
|
|
46
|
-
"A description of this Speech Provider, shown in the UI."
|
|
47
|
-
)),
|
|
34
|
+
description: ( localizeWithPath(_moduleId, 2, "A description of this Speech Provider, shown in the UI.")),
|
|
48
35
|
type: 'string'
|
|
49
36
|
}
|
|
50
37
|
}
|
|
@@ -53,29 +40,28 @@ const speechProvidersExtensionPoint = ExtensionsRegistry.registerExtensionPoint(
|
|
|
53
40
|
});
|
|
54
41
|
let SpeechService = class SpeechService extends Disposable {
|
|
55
42
|
get hasSpeechProvider() { return this.providerDescriptors.size > 0 || this.providers.size > 0; }
|
|
56
|
-
constructor(logService, contextKeyService, hostService, telemetryService, configurationService,
|
|
43
|
+
constructor(logService, contextKeyService, hostService, telemetryService, configurationService, extensionService) {
|
|
57
44
|
super();
|
|
58
45
|
this.logService = logService;
|
|
59
46
|
this.contextKeyService = contextKeyService;
|
|
60
47
|
this.hostService = hostService;
|
|
61
48
|
this.telemetryService = telemetryService;
|
|
62
49
|
this.configurationService = configurationService;
|
|
63
|
-
this.accessibilitySignalService = accessibilitySignalService;
|
|
64
50
|
this.extensionService = extensionService;
|
|
65
|
-
this._onDidChangeHasSpeechProvider = this._register(( new Emitter()));
|
|
51
|
+
this._onDidChangeHasSpeechProvider = this._register(( (new Emitter())));
|
|
66
52
|
this.onDidChangeHasSpeechProvider = this._onDidChangeHasSpeechProvider.event;
|
|
67
|
-
this.providers = ( new Map());
|
|
68
|
-
this.providerDescriptors = ( new Map());
|
|
53
|
+
this.providers = ( (new Map()));
|
|
54
|
+
this.providerDescriptors = ( (new Map()));
|
|
69
55
|
this.hasSpeechProviderContext = HasSpeechProvider.bindTo(this.contextKeyService);
|
|
70
|
-
this._onDidStartSpeechToTextSession = this._register(( new Emitter()));
|
|
56
|
+
this._onDidStartSpeechToTextSession = this._register(( (new Emitter())));
|
|
71
57
|
this.onDidStartSpeechToTextSession = this._onDidStartSpeechToTextSession.event;
|
|
72
|
-
this._onDidEndSpeechToTextSession = this._register(( new Emitter()));
|
|
58
|
+
this._onDidEndSpeechToTextSession = this._register(( (new Emitter())));
|
|
73
59
|
this.onDidEndSpeechToTextSession = this._onDidEndSpeechToTextSession.event;
|
|
74
60
|
this._activeSpeechToTextSession = undefined;
|
|
75
61
|
this.speechToTextInProgress = SpeechToTextInProgress.bindTo(this.contextKeyService);
|
|
76
|
-
this._onDidStartKeywordRecognition = this._register(( new Emitter()));
|
|
62
|
+
this._onDidStartKeywordRecognition = this._register(( (new Emitter())));
|
|
77
63
|
this.onDidStartKeywordRecognition = this._onDidStartKeywordRecognition.event;
|
|
78
|
-
this._onDidEndKeywordRecognition = this._register(( new Emitter()));
|
|
64
|
+
this._onDidEndKeywordRecognition = this._register(( (new Emitter())));
|
|
79
65
|
this.onDidEndKeywordRecognition = this._onDidEndKeywordRecognition.event;
|
|
80
66
|
this._activeKeywordRecognitionSession = undefined;
|
|
81
67
|
this.handleAndRegisterSpeechExtensions();
|
|
@@ -99,8 +85,8 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
99
85
|
});
|
|
100
86
|
}
|
|
101
87
|
registerSpeechProvider(identifier, provider) {
|
|
102
|
-
if (( this.providers.has(identifier))) {
|
|
103
|
-
throw new Error(`Speech provider with identifier ${identifier} is already registered.`);
|
|
88
|
+
if (( (this.providers.has(identifier)))) {
|
|
89
|
+
throw ( (new Error(`Speech provider with identifier ${identifier} is already registered.`)));
|
|
104
90
|
}
|
|
105
91
|
const oldHasSpeechProvider = this.hasSpeechProvider;
|
|
106
92
|
this.providers.set(identifier, provider);
|
|
@@ -126,18 +112,19 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
126
112
|
const session = this._activeSpeechToTextSession = provider.createSpeechToTextSession(token, typeof language === 'string' ? { language } : undefined);
|
|
127
113
|
const sessionStart = Date.now();
|
|
128
114
|
let sessionRecognized = false;
|
|
115
|
+
let sessionError = false;
|
|
129
116
|
let sessionContentLength = 0;
|
|
130
|
-
const disposables = ( new DisposableStore());
|
|
117
|
+
const disposables = ( (new DisposableStore()));
|
|
131
118
|
const onSessionStoppedOrCanceled = () => {
|
|
132
119
|
if (session === this._activeSpeechToTextSession) {
|
|
133
120
|
this._activeSpeechToTextSession = undefined;
|
|
134
121
|
this.speechToTextInProgress.reset();
|
|
135
|
-
this.accessibilitySignalService.playSignal(AccessibilitySignal.voiceRecordingStopped, { allowManyInParallel: true });
|
|
136
122
|
this._onDidEndSpeechToTextSession.fire();
|
|
137
123
|
this.telemetryService.publicLog2('speechToTextSession', {
|
|
138
124
|
context,
|
|
139
125
|
sessionDuration: Date.now() - sessionStart,
|
|
140
126
|
sessionRecognized,
|
|
127
|
+
sessionError,
|
|
141
128
|
sessionContentLength,
|
|
142
129
|
sessionLanguage: language
|
|
143
130
|
});
|
|
@@ -154,7 +141,6 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
154
141
|
if (session === this._activeSpeechToTextSession) {
|
|
155
142
|
this.speechToTextInProgress.set(true);
|
|
156
143
|
this._onDidStartSpeechToTextSession.fire();
|
|
157
|
-
this.accessibilitySignalService.playSignal(AccessibilitySignal.voiceRecordingStarted);
|
|
158
144
|
}
|
|
159
145
|
break;
|
|
160
146
|
case SpeechToTextStatus.Recognizing:
|
|
@@ -168,15 +154,19 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
168
154
|
case SpeechToTextStatus.Stopped:
|
|
169
155
|
onSessionStoppedOrCanceled();
|
|
170
156
|
break;
|
|
157
|
+
case SpeechToTextStatus.Error:
|
|
158
|
+
this.logService.error(`Speech provider error in speech to text session: ${e.text}`);
|
|
159
|
+
sessionError = true;
|
|
160
|
+
break;
|
|
171
161
|
}
|
|
172
162
|
}));
|
|
173
163
|
return session;
|
|
174
164
|
}
|
|
175
165
|
async getProvider() {
|
|
176
166
|
await this.extensionService.activateByEvent('onSpeech');
|
|
177
|
-
const provider = firstOrDefault(Array.from(( this.providers.values())));
|
|
167
|
+
const provider = firstOrDefault(Array.from(( (this.providers.values()))));
|
|
178
168
|
if (!provider) {
|
|
179
|
-
throw new Error(`No Speech provider is registered.`);
|
|
169
|
+
throw ( (new Error(`No Speech provider is registered.`)));
|
|
180
170
|
}
|
|
181
171
|
else if (this.providers.size > 1) {
|
|
182
172
|
this.logService.warn(`Multiple speech providers registered. Picking first one: ${provider.metadata.displayName}`);
|
|
@@ -185,18 +175,18 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
185
175
|
}
|
|
186
176
|
get hasActiveKeywordRecognition() { return !!this._activeKeywordRecognitionSession; }
|
|
187
177
|
async recognizeKeyword(token) {
|
|
188
|
-
const result = ( new DeferredPromise());
|
|
178
|
+
const result = ( (new DeferredPromise()));
|
|
189
179
|
await this.extensionService.activateByEvent('onSpeech');
|
|
190
|
-
const disposables = ( new DisposableStore());
|
|
180
|
+
const disposables = ( (new DisposableStore()));
|
|
191
181
|
disposables.add(token.onCancellationRequested(() => {
|
|
192
182
|
disposables.dispose();
|
|
193
183
|
result.complete(KeywordRecognitionStatus.Canceled);
|
|
194
184
|
}));
|
|
195
|
-
const recognizeKeywordDisposables = disposables.add(( new DisposableStore()));
|
|
185
|
+
const recognizeKeywordDisposables = disposables.add(( (new DisposableStore())));
|
|
196
186
|
let activeRecognizeKeywordSession = undefined;
|
|
197
187
|
const recognizeKeyword = () => {
|
|
198
188
|
recognizeKeywordDisposables.clear();
|
|
199
|
-
const cts = ( new CancellationTokenSource(token));
|
|
189
|
+
const cts = ( (new CancellationTokenSource(token)));
|
|
200
190
|
recognizeKeywordDisposables.add(toDisposable(() => cts.dispose(true)));
|
|
201
191
|
const currentRecognizeKeywordSession = activeRecognizeKeywordSession = this.doRecognizeKeyword(cts.token).then(status => {
|
|
202
192
|
if (currentRecognizeKeywordSession === activeRecognizeKeywordSession) {
|
|
@@ -236,7 +226,7 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
236
226
|
const provider = await this.getProvider();
|
|
237
227
|
const session = this._activeKeywordRecognitionSession = provider.createKeywordRecognitionSession(token);
|
|
238
228
|
this._onDidStartKeywordRecognition.fire();
|
|
239
|
-
const disposables = ( new DisposableStore());
|
|
229
|
+
const disposables = ( (new DisposableStore()));
|
|
240
230
|
const onSessionStoppedOrCanceled = () => {
|
|
241
231
|
if (session === this._activeKeywordRecognitionSession) {
|
|
242
232
|
this._activeKeywordRecognitionSession = undefined;
|
|
@@ -261,14 +251,13 @@ let SpeechService = class SpeechService extends Disposable {
|
|
|
261
251
|
}
|
|
262
252
|
}
|
|
263
253
|
};
|
|
264
|
-
SpeechService = ( __decorate([
|
|
265
|
-
( __param(0, ILogService)),
|
|
266
|
-
( __param(1, IContextKeyService)),
|
|
267
|
-
( __param(2, IHostService)),
|
|
268
|
-
( __param(3, ITelemetryService)),
|
|
269
|
-
( __param(4, IConfigurationService)),
|
|
270
|
-
( __param(5,
|
|
271
|
-
|
|
272
|
-
], SpeechService));
|
|
254
|
+
SpeechService = ( (__decorate([
|
|
255
|
+
( (__param(0, ILogService))),
|
|
256
|
+
( (__param(1, IContextKeyService))),
|
|
257
|
+
( (__param(2, IHostService))),
|
|
258
|
+
( (__param(3, ITelemetryService))),
|
|
259
|
+
( (__param(4, IConfigurationService))),
|
|
260
|
+
( (__param(5, IExtensionService)))
|
|
261
|
+
], SpeechService)));
|
|
273
262
|
|
|
274
263
|
export { SpeechService };
|