web-speech-cognitive-services 8.0.0-main.428d2a8 → 8.0.0-main.5903868
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/dist/web-speech-cognitive-services.d.mts +123 -26
- package/dist/web-speech-cognitive-services.d.ts +123 -26
- package/dist/web-speech-cognitive-services.development.js +1339 -1251
- package/dist/web-speech-cognitive-services.development.js.map +1 -1
- package/dist/web-speech-cognitive-services.js +225 -140
- package/dist/web-speech-cognitive-services.js.map +1 -1
- package/dist/web-speech-cognitive-services.mjs +220 -135
- package/dist/web-speech-cognitive-services.mjs.map +1 -1
- package/dist/web-speech-cognitive-services.production.min.js +12 -12
- package/dist/web-speech-cognitive-services.production.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.js
|
|
2
|
-
import { Event, EventTarget, getEventAttributeValue, setEventAttributeValue } from "event-target-shim";
|
|
3
|
-
|
|
4
1
|
// ../../node_modules/p-defer/index.js
|
|
5
2
|
function pDefer() {
|
|
6
3
|
const deferred = {};
|
|
@@ -135,53 +132,111 @@ var SpeechSDK_default = {
|
|
|
135
132
|
SpeechRecognizer
|
|
136
133
|
};
|
|
137
134
|
|
|
138
|
-
// src/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
135
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionAlternative.ts
|
|
136
|
+
var SpeechRecognitionAlternative = class {
|
|
137
|
+
constructor({ confidence, transcript }) {
|
|
138
|
+
this.#confidence = confidence;
|
|
139
|
+
this.#transcript = transcript;
|
|
140
|
+
}
|
|
141
|
+
#confidence;
|
|
142
|
+
#transcript;
|
|
143
|
+
get confidence() {
|
|
144
|
+
return this.#confidence;
|
|
145
|
+
}
|
|
146
|
+
get transcript() {
|
|
147
|
+
return this.#transcript;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/SpeechServices/SpeechToText/FakeArray.ts
|
|
152
|
+
var FakeArray = class {
|
|
153
|
+
constructor(array) {
|
|
154
|
+
if (!array) {
|
|
155
|
+
throw new Error("array must be set.");
|
|
156
|
+
}
|
|
157
|
+
this.#array = array;
|
|
158
|
+
for (const key in array) {
|
|
159
|
+
Object.defineProperty(this, key, {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get() {
|
|
162
|
+
return array[key];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
#array;
|
|
168
|
+
[Symbol.iterator]() {
|
|
169
|
+
return this.#array[Symbol.iterator]();
|
|
170
|
+
}
|
|
171
|
+
get length() {
|
|
172
|
+
return this.#array.length;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionResult.ts
|
|
177
|
+
var SpeechRecognitionResult = class extends FakeArray {
|
|
178
|
+
constructor(init) {
|
|
179
|
+
super(init.results);
|
|
180
|
+
this.#isFinal = init.isFinal;
|
|
181
|
+
}
|
|
182
|
+
#isFinal;
|
|
183
|
+
get isFinal() {
|
|
184
|
+
return this.#isFinal;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
155
187
|
|
|
156
|
-
// src/SpeechServices/SpeechToText/
|
|
188
|
+
// src/SpeechServices/SpeechToText/cognitiveServiceEventResultToWebSpeechRecognitionResult.ts
|
|
157
189
|
var {
|
|
158
190
|
ResultReason: { RecognizingSpeech, RecognizedSpeech }
|
|
159
191
|
} = SpeechSDK_default;
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
192
|
+
function cognitiveServiceEventResultToWebSpeechRecognitionResult_default(result, init) {
|
|
193
|
+
const { maxAlternatives = Infinity, textNormalization = "display" } = init || {};
|
|
194
|
+
const json = typeof result.json === "string" ? JSON.parse(result.json) : result.json;
|
|
195
|
+
if (result.reason === RecognizingSpeech || result.reason === RecognizedSpeech && !json.NBest) {
|
|
196
|
+
return new SpeechRecognitionResult({
|
|
197
|
+
isFinal: result.reason === RecognizedSpeech,
|
|
198
|
+
results: [
|
|
199
|
+
new SpeechRecognitionAlternative({
|
|
200
|
+
confidence: 0.5,
|
|
201
|
+
transcript: result.text
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
});
|
|
172
205
|
} else if (result.reason === RecognizedSpeech) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
206
|
+
return new SpeechRecognitionResult({
|
|
207
|
+
isFinal: true,
|
|
208
|
+
results: (json.NBest || []).slice(0, maxAlternatives).map(
|
|
209
|
+
({ Confidence: confidence, Display: display, ITN: itn, Lexical: lexical, MaskedITN: maskedITN }) => new SpeechRecognitionAlternative({
|
|
210
|
+
confidence,
|
|
211
|
+
transcript: textNormalization === "itn" ? itn : textNormalization === "lexical" ? lexical : textNormalization === "maskeditn" ? maskedITN : display
|
|
212
|
+
})
|
|
213
|
+
)
|
|
214
|
+
});
|
|
181
215
|
}
|
|
182
|
-
return [];
|
|
216
|
+
return new SpeechRecognitionResult({ isFinal: false, results: [] });
|
|
183
217
|
}
|
|
184
218
|
|
|
219
|
+
// src/SpeechServices/SpeechToText/EventListenerMap.ts
|
|
220
|
+
var EventListenerMap = class {
|
|
221
|
+
constructor(eventTarget) {
|
|
222
|
+
this.#eventTarget = eventTarget;
|
|
223
|
+
this.#propertyMap = {};
|
|
224
|
+
}
|
|
225
|
+
#eventTarget;
|
|
226
|
+
#propertyMap;
|
|
227
|
+
getProperty(name) {
|
|
228
|
+
return this.#propertyMap[name];
|
|
229
|
+
}
|
|
230
|
+
setProperty(name, value) {
|
|
231
|
+
const existing = this.#propertyMap[name];
|
|
232
|
+
existing && this.#eventTarget.removeEventListener(name, existing);
|
|
233
|
+
if (value) {
|
|
234
|
+
this.#eventTarget.addEventListener(name, value);
|
|
235
|
+
}
|
|
236
|
+
this.#propertyMap[name] = value;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
185
240
|
// src/SpeechServices/SpeechToText/SpeechGrammarList.js
|
|
186
241
|
var SpeechGrammarList_default = class {
|
|
187
242
|
constructor() {
|
|
@@ -204,6 +259,53 @@ var SpeechGrammarList_default = class {
|
|
|
204
259
|
}
|
|
205
260
|
};
|
|
206
261
|
|
|
262
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionErrorEvent.ts
|
|
263
|
+
var SpeechRecognitionErrorEvent = class extends Event {
|
|
264
|
+
constructor(type, { error, message }) {
|
|
265
|
+
super(type);
|
|
266
|
+
this.#error = error;
|
|
267
|
+
this.#message = message;
|
|
268
|
+
}
|
|
269
|
+
#error;
|
|
270
|
+
#message;
|
|
271
|
+
get error() {
|
|
272
|
+
return this.#error;
|
|
273
|
+
}
|
|
274
|
+
get message() {
|
|
275
|
+
return this.#message;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionResultList.ts
|
|
280
|
+
var SpeechRecognitionResultList = class extends FakeArray {
|
|
281
|
+
constructor(result) {
|
|
282
|
+
super(result);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionEvent.ts
|
|
287
|
+
var SpeechRecognitionEvent = class extends Event {
|
|
288
|
+
constructor(type, { data, resultIndex, results } = {}) {
|
|
289
|
+
super(type);
|
|
290
|
+
this.#data = data;
|
|
291
|
+
this.#resultIndex = resultIndex;
|
|
292
|
+
this.#results = results || new SpeechRecognitionResultList([]);
|
|
293
|
+
}
|
|
294
|
+
#data;
|
|
295
|
+
// TODO: "resultIndex" should be set.
|
|
296
|
+
#resultIndex;
|
|
297
|
+
#results;
|
|
298
|
+
get data() {
|
|
299
|
+
return this.#data;
|
|
300
|
+
}
|
|
301
|
+
get resultIndex() {
|
|
302
|
+
return this.#resultIndex;
|
|
303
|
+
}
|
|
304
|
+
get results() {
|
|
305
|
+
return this.#results;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
207
309
|
// src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.js
|
|
208
310
|
var { AudioConfig: AudioConfig2, OutputFormat: OutputFormat2, ResultReason: ResultReason2, SpeechConfig: SpeechConfig2, SpeechRecognizer: SpeechRecognizer2 } = SpeechSDK_default;
|
|
209
311
|
function serializeRecognitionResult({ duration, errorDetails, json, offset, properties, reason, resultId, text }) {
|
|
@@ -225,16 +327,6 @@ function averageAmplitude(arrayBuffer) {
|
|
|
225
327
|
function cognitiveServicesAsyncToPromise(fn) {
|
|
226
328
|
return (...args) => new Promise((resolve, reject) => fn(...args, resolve, reject));
|
|
227
329
|
}
|
|
228
|
-
var SpeechRecognitionEvent = class extends Event {
|
|
229
|
-
constructor(type, { data, emma, interpretation, resultIndex, results } = {}) {
|
|
230
|
-
super(type);
|
|
231
|
-
this.data = data;
|
|
232
|
-
this.emma = emma;
|
|
233
|
-
this.interpretation = interpretation;
|
|
234
|
-
this.resultIndex = resultIndex;
|
|
235
|
-
this.results = results;
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
330
|
function prepareAudioConfig(audioConfig) {
|
|
239
331
|
const originalAttach = audioConfig.attach;
|
|
240
332
|
const boundOriginalAttach = audioConfig.attach.bind(audioConfig);
|
|
@@ -283,7 +375,10 @@ function createSpeechRecognitionPonyfillFromRecognizer({
|
|
|
283
375
|
this._lang = typeof window !== "undefined" ? window.document.documentElement.getAttribute("lang") || window.navigator.language : "en-US";
|
|
284
376
|
this._grammars = new SpeechGrammarList_default();
|
|
285
377
|
this._maxAlternatives = 1;
|
|
378
|
+
this.#eventListenerMap = new EventListenerMap(this);
|
|
286
379
|
}
|
|
380
|
+
/** @type { import('./SpeechRecognitionEventListenerMap').SpeechRecognitionEventListenerMap } */
|
|
381
|
+
#eventListenerMap;
|
|
287
382
|
emitCognitiveServices(type, event) {
|
|
288
383
|
this.dispatchEvent(
|
|
289
384
|
new SpeechRecognitionEvent("cognitiveservices", {
|
|
@@ -328,75 +423,88 @@ function createSpeechRecognitionPonyfillFromRecognizer({
|
|
|
328
423
|
set lang(value) {
|
|
329
424
|
this._lang = value;
|
|
330
425
|
}
|
|
426
|
+
/** @type { ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined } */
|
|
331
427
|
get onaudioend() {
|
|
332
|
-
return
|
|
428
|
+
return this.#eventListenerMap.getProperty("audioend");
|
|
333
429
|
}
|
|
334
430
|
set onaudioend(value) {
|
|
335
|
-
|
|
431
|
+
this.#eventListenerMap.setProperty("audioend", value);
|
|
336
432
|
}
|
|
433
|
+
/** @type { ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined } */
|
|
337
434
|
get onaudiostart() {
|
|
338
|
-
return
|
|
435
|
+
return this.#eventListenerMap.getProperty("audiostart");
|
|
339
436
|
}
|
|
340
437
|
set onaudiostart(value) {
|
|
341
|
-
|
|
438
|
+
this.#eventListenerMap.setProperty("audiostart", value);
|
|
342
439
|
}
|
|
440
|
+
/** @type { ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined } */
|
|
343
441
|
get oncognitiveservices() {
|
|
344
|
-
return
|
|
442
|
+
return this.#eventListenerMap.getProperty("cognitiveservices");
|
|
345
443
|
}
|
|
346
444
|
set oncognitiveservices(value) {
|
|
347
|
-
|
|
445
|
+
this.#eventListenerMap.setProperty("cognitiveservices", value);
|
|
348
446
|
}
|
|
447
|
+
/** @type { ((event: SpeechRecognitionEvent<'end'>) => void) | undefined } */
|
|
349
448
|
get onend() {
|
|
350
|
-
return
|
|
449
|
+
return this.#eventListenerMap.getProperty("end");
|
|
351
450
|
}
|
|
352
451
|
set onend(value) {
|
|
353
|
-
|
|
452
|
+
this.#eventListenerMap.setProperty("end", value);
|
|
354
453
|
}
|
|
454
|
+
/** @type { ((event: SpeechRecognitionEvent<'error'>) => void) | undefined } */
|
|
355
455
|
get onerror() {
|
|
356
|
-
return
|
|
456
|
+
return this.#eventListenerMap.getProperty("error");
|
|
357
457
|
}
|
|
358
458
|
set onerror(value) {
|
|
359
|
-
|
|
459
|
+
this.#eventListenerMap.setProperty("error", value);
|
|
360
460
|
}
|
|
461
|
+
/** @type { ((event: SpeechRecognitionEvent<'result'>) => void) | undefined } */
|
|
361
462
|
get onresult() {
|
|
362
|
-
return
|
|
463
|
+
return this.#eventListenerMap.getProperty("result");
|
|
363
464
|
}
|
|
364
465
|
set onresult(value) {
|
|
365
|
-
|
|
466
|
+
this.#eventListenerMap.setProperty("result", value);
|
|
366
467
|
}
|
|
468
|
+
/** @type { ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined } */
|
|
367
469
|
get onsoundend() {
|
|
368
|
-
return
|
|
470
|
+
return this.#eventListenerMap.getProperty("soundend");
|
|
369
471
|
}
|
|
370
472
|
set onsoundend(value) {
|
|
371
|
-
|
|
473
|
+
this.#eventListenerMap.setProperty("soundend", value);
|
|
372
474
|
}
|
|
475
|
+
/** @type { ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined } */
|
|
373
476
|
get onsoundstart() {
|
|
374
|
-
return
|
|
477
|
+
return this.#eventListenerMap.getProperty("soundstart");
|
|
375
478
|
}
|
|
376
479
|
set onsoundstart(value) {
|
|
377
|
-
|
|
480
|
+
this.#eventListenerMap.setProperty("soundstart", value);
|
|
378
481
|
}
|
|
482
|
+
/** @type { ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined } */
|
|
379
483
|
get onspeechend() {
|
|
380
|
-
return
|
|
484
|
+
return this.#eventListenerMap.getProperty("speechend");
|
|
381
485
|
}
|
|
382
486
|
set onspeechend(value) {
|
|
383
|
-
|
|
487
|
+
this.#eventListenerMap.setProperty("speechend", value);
|
|
384
488
|
}
|
|
489
|
+
/** @type { ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined } */
|
|
385
490
|
get onspeechstart() {
|
|
386
|
-
return
|
|
491
|
+
return this.#eventListenerMap.getProperty("speechstart");
|
|
387
492
|
}
|
|
388
493
|
set onspeechstart(value) {
|
|
389
|
-
|
|
494
|
+
this.#eventListenerMap.setProperty("speechstart", value);
|
|
390
495
|
}
|
|
496
|
+
/** @type { ((event: SpeechRecognitionEvent<'start'>) => void) | undefined } */
|
|
391
497
|
get onstart() {
|
|
392
|
-
return
|
|
498
|
+
return this.#eventListenerMap.getProperty("start");
|
|
393
499
|
}
|
|
394
500
|
set onstart(value) {
|
|
395
|
-
|
|
501
|
+
this.#eventListenerMap.setProperty("start", value);
|
|
396
502
|
}
|
|
397
503
|
start() {
|
|
398
504
|
this._startOnce().catch((err) => {
|
|
399
|
-
this.dispatchEvent(
|
|
505
|
+
this.dispatchEvent(
|
|
506
|
+
new SpeechRecognitionErrorEvent("error", { error: err, message: err && (err.stack || err.message) })
|
|
507
|
+
);
|
|
400
508
|
});
|
|
401
509
|
}
|
|
402
510
|
async _startOnce() {
|
|
@@ -486,10 +594,7 @@ function createSpeechRecognitionPonyfillFromRecognizer({
|
|
|
486
594
|
Object.keys(event).forEach((name) => this.emitCognitiveServices(name, event[name]));
|
|
487
595
|
const errorMessage = canceled && canceled.errorDetails;
|
|
488
596
|
if (/Permission\sdenied/u.test(errorMessage || "")) {
|
|
489
|
-
finalEvent = {
|
|
490
|
-
error: "not-allowed",
|
|
491
|
-
type: "error"
|
|
492
|
-
};
|
|
597
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "not-allowed" });
|
|
493
598
|
break;
|
|
494
599
|
}
|
|
495
600
|
if (!loop) {
|
|
@@ -501,23 +606,14 @@ function createSpeechRecognitionPonyfillFromRecognizer({
|
|
|
501
606
|
this.dispatchEvent(new SpeechRecognitionEvent("audiostart"));
|
|
502
607
|
this.dispatchEvent(new SpeechRecognitionEvent("audioend"));
|
|
503
608
|
}
|
|
504
|
-
finalEvent = {
|
|
505
|
-
error: "network",
|
|
506
|
-
type: "error"
|
|
507
|
-
};
|
|
609
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "network" });
|
|
508
610
|
} else {
|
|
509
|
-
finalEvent = {
|
|
510
|
-
error: "unknown",
|
|
511
|
-
type: "error"
|
|
512
|
-
};
|
|
611
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "unknown" });
|
|
513
612
|
}
|
|
514
613
|
break;
|
|
515
614
|
} else if (abort || stop) {
|
|
516
615
|
if (abort) {
|
|
517
|
-
finalEvent = {
|
|
518
|
-
error: "aborted",
|
|
519
|
-
type: "error"
|
|
520
|
-
};
|
|
616
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "aborted" });
|
|
521
617
|
stopping = "abort";
|
|
522
618
|
} else {
|
|
523
619
|
pause();
|
|
@@ -541,10 +637,7 @@ function createSpeechRecognitionPonyfillFromRecognizer({
|
|
|
541
637
|
} else if (stopping !== "abort") {
|
|
542
638
|
if (recognized && recognized.result && recognized.result.reason === ResultReason2.NoMatch) {
|
|
543
639
|
if (!this.continuous || stopping === "stop") {
|
|
544
|
-
finalEvent = {
|
|
545
|
-
results: [],
|
|
546
|
-
type: "result"
|
|
547
|
-
};
|
|
640
|
+
finalEvent = new SpeechRecognitionEvent("result", { results: finalizedResults });
|
|
548
641
|
recognizer.stopContinuousRecognitionAsync && await cognitiveServicesAsyncToPromise(recognizer.stopContinuousRecognitionAsync.bind(recognizer))();
|
|
549
642
|
break;
|
|
550
643
|
}
|
|
@@ -562,7 +655,7 @@ function createSpeechRecognitionPonyfillFromRecognizer({
|
|
|
562
655
|
speechStarted = true;
|
|
563
656
|
}
|
|
564
657
|
if (recognized) {
|
|
565
|
-
const result =
|
|
658
|
+
const result = cognitiveServiceEventResultToWebSpeechRecognitionResult_default(recognized.result, {
|
|
566
659
|
maxAlternatives: this.maxAlternatives,
|
|
567
660
|
textNormalization
|
|
568
661
|
});
|
|
@@ -571,35 +664,34 @@ function createSpeechRecognitionPonyfillFromRecognizer({
|
|
|
571
664
|
finalizedResults = [...finalizedResults, result];
|
|
572
665
|
this.continuous && this.dispatchEvent(
|
|
573
666
|
new SpeechRecognitionEvent("result", {
|
|
574
|
-
results: finalizedResults
|
|
667
|
+
results: new SpeechRecognitionResultList(finalizedResults)
|
|
575
668
|
})
|
|
576
669
|
);
|
|
577
670
|
}
|
|
578
671
|
if (this.continuous && recognizable) {
|
|
579
|
-
finalEvent =
|
|
672
|
+
finalEvent = void 0;
|
|
580
673
|
} else {
|
|
581
|
-
finalEvent = {
|
|
582
|
-
results: finalizedResults
|
|
583
|
-
|
|
584
|
-
};
|
|
674
|
+
finalEvent = new SpeechRecognitionEvent("result", {
|
|
675
|
+
results: new SpeechRecognitionResultList(finalizedResults)
|
|
676
|
+
});
|
|
585
677
|
}
|
|
586
678
|
if ((!this.continuous || stopping === "stop") && recognizer.stopContinuousRecognitionAsync) {
|
|
587
679
|
await cognitiveServicesAsyncToPromise(recognizer.stopContinuousRecognitionAsync.bind(recognizer))();
|
|
588
680
|
}
|
|
589
681
|
if (looseEvents && finalEvent && recognizable) {
|
|
590
|
-
this.dispatchEvent(
|
|
591
|
-
finalEvent =
|
|
682
|
+
this.dispatchEvent(finalEvent);
|
|
683
|
+
finalEvent = void 0;
|
|
592
684
|
}
|
|
593
685
|
} else if (recognizing) {
|
|
594
686
|
this.interimResults && this.dispatchEvent(
|
|
595
687
|
new SpeechRecognitionEvent("result", {
|
|
596
|
-
results: [
|
|
688
|
+
results: new SpeechRecognitionResultList([
|
|
597
689
|
...finalizedResults,
|
|
598
|
-
|
|
690
|
+
cognitiveServiceEventResultToWebSpeechRecognitionResult_default(recognizing.result, {
|
|
599
691
|
maxAlternatives: this.maxAlternatives,
|
|
600
692
|
textNormalization
|
|
601
693
|
})
|
|
602
|
-
]
|
|
694
|
+
])
|
|
603
695
|
})
|
|
604
696
|
);
|
|
605
697
|
}
|
|
@@ -617,16 +709,9 @@ function createSpeechRecognitionPonyfillFromRecognizer({
|
|
|
617
709
|
}
|
|
618
710
|
if (finalEvent) {
|
|
619
711
|
if (finalEvent.type === "result" && !finalEvent.results.length) {
|
|
620
|
-
finalEvent = {
|
|
621
|
-
error: "no-speech",
|
|
622
|
-
type: "error"
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
if (finalEvent.type === "error") {
|
|
626
|
-
this.dispatchEvent(new ErrorEvent("error", finalEvent));
|
|
627
|
-
} else {
|
|
628
|
-
this.dispatchEvent(new SpeechRecognitionEvent(finalEvent.type, finalEvent));
|
|
712
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "no-speech" });
|
|
629
713
|
}
|
|
714
|
+
this.dispatchEvent(finalEvent);
|
|
630
715
|
}
|
|
631
716
|
this.dispatchEvent(new SpeechRecognitionEvent("end"));
|
|
632
717
|
detachAudioConfigEvent();
|
|
@@ -698,7 +783,7 @@ var createSpeechRecognitionPonyfill_default = (options) => {
|
|
|
698
783
|
var SpeechToText_default = createSpeechRecognitionPonyfill_default;
|
|
699
784
|
|
|
700
785
|
// src/SpeechServices/TextToSpeech/createSpeechSynthesisPonyfill.js
|
|
701
|
-
import { EventTarget as EventTarget3, getEventAttributeValue as
|
|
786
|
+
import { EventTarget as EventTarget3, getEventAttributeValue as getEventAttributeValue2, setEventAttributeValue as setEventAttributeValue2 } from "event-target-shim";
|
|
702
787
|
import { onErrorResumeNext } from "on-error-resume-next/async";
|
|
703
788
|
|
|
704
789
|
// src/SpeechServices/TextToSpeech/AudioContextQueue.js
|
|
@@ -783,7 +868,7 @@ var SpeechSynthesisEvent = class extends Event2 {
|
|
|
783
868
|
|
|
784
869
|
// src/SpeechServices/TextToSpeech/SpeechSynthesisUtterance.js
|
|
785
870
|
import { EventAsPromise } from "event-as-promise";
|
|
786
|
-
import { EventTarget as EventTarget2, getEventAttributeValue
|
|
871
|
+
import { EventTarget as EventTarget2, getEventAttributeValue, setEventAttributeValue } from "event-target-shim";
|
|
787
872
|
|
|
788
873
|
// src/SpeechServices/TextToSpeech/fetchSpeechData.js
|
|
789
874
|
import { decode } from "base64-arraybuffer";
|
|
@@ -922,46 +1007,46 @@ var SpeechSynthesisUtterance = class extends EventTarget2 {
|
|
|
922
1007
|
this._lang = value;
|
|
923
1008
|
}
|
|
924
1009
|
get onboundary() {
|
|
925
|
-
return
|
|
1010
|
+
return getEventAttributeValue(this, "boundary");
|
|
926
1011
|
}
|
|
927
1012
|
set onboundary(value) {
|
|
928
|
-
|
|
1013
|
+
setEventAttributeValue(this, "boundary", value);
|
|
929
1014
|
}
|
|
930
1015
|
get onend() {
|
|
931
|
-
return
|
|
1016
|
+
return getEventAttributeValue(this, "end");
|
|
932
1017
|
}
|
|
933
1018
|
set onend(value) {
|
|
934
|
-
|
|
1019
|
+
setEventAttributeValue(this, "end", value);
|
|
935
1020
|
}
|
|
936
1021
|
get onerror() {
|
|
937
|
-
return
|
|
1022
|
+
return getEventAttributeValue(this, "error");
|
|
938
1023
|
}
|
|
939
1024
|
set onerror(value) {
|
|
940
|
-
|
|
1025
|
+
setEventAttributeValue(this, "error", value);
|
|
941
1026
|
}
|
|
942
1027
|
get onmark() {
|
|
943
|
-
return
|
|
1028
|
+
return getEventAttributeValue(this, "mark");
|
|
944
1029
|
}
|
|
945
1030
|
set onmark(value) {
|
|
946
|
-
|
|
1031
|
+
setEventAttributeValue(this, "mark", value);
|
|
947
1032
|
}
|
|
948
1033
|
get onpause() {
|
|
949
|
-
return
|
|
1034
|
+
return getEventAttributeValue(this, "pause");
|
|
950
1035
|
}
|
|
951
1036
|
set onpause(value) {
|
|
952
|
-
|
|
1037
|
+
setEventAttributeValue(this, "pause", value);
|
|
953
1038
|
}
|
|
954
1039
|
get onresume() {
|
|
955
|
-
return
|
|
1040
|
+
return getEventAttributeValue(this, "resume");
|
|
956
1041
|
}
|
|
957
1042
|
set onresume(value) {
|
|
958
|
-
|
|
1043
|
+
setEventAttributeValue(this, "resume", value);
|
|
959
1044
|
}
|
|
960
1045
|
get onstart() {
|
|
961
|
-
return
|
|
1046
|
+
return getEventAttributeValue(this, "start");
|
|
962
1047
|
}
|
|
963
1048
|
set onstart(value) {
|
|
964
|
-
|
|
1049
|
+
setEventAttributeValue(this, "start", value);
|
|
965
1050
|
}
|
|
966
1051
|
get pitch() {
|
|
967
1052
|
return this._pitch;
|
|
@@ -1126,10 +1211,10 @@ var createSpeechSynthesisPonyfill_default = (options) => {
|
|
|
1126
1211
|
return EMPTY_ARRAY;
|
|
1127
1212
|
}
|
|
1128
1213
|
get onvoiceschanged() {
|
|
1129
|
-
return
|
|
1214
|
+
return getEventAttributeValue2(this, "voiceschanged");
|
|
1130
1215
|
}
|
|
1131
1216
|
set onvoiceschanged(value) {
|
|
1132
|
-
|
|
1217
|
+
setEventAttributeValue2(this, "voiceschanged", value);
|
|
1133
1218
|
}
|
|
1134
1219
|
pause() {
|
|
1135
1220
|
this.queue.pause();
|
|
@@ -1224,7 +1309,7 @@ function createSpeechServicesPonyfill(options = {}, ...args) {
|
|
|
1224
1309
|
}
|
|
1225
1310
|
var meta = document.createElement("meta");
|
|
1226
1311
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
1227
|
-
meta.setAttribute("content", `version=${"8.0.0-main.
|
|
1312
|
+
meta.setAttribute("content", `version=${"8.0.0-main.5903868"}`);
|
|
1228
1313
|
document.head.appendChild(meta);
|
|
1229
1314
|
export {
|
|
1230
1315
|
SpeechToText_default as createSpeechRecognitionPonyfill,
|