web-speech-cognitive-services 8.0.0-main.ccf35da → 8.0.0-main.d9ef940
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 +49 -13
- package/dist/web-speech-cognitive-services.d.ts +49 -13
- package/dist/web-speech-cognitive-services.development.js +120 -113
- package/dist/web-speech-cognitive-services.development.js.map +1 -1
- package/dist/web-speech-cognitive-services.js +126 -116
- package/dist/web-speech-cognitive-services.js.map +1 -1
- package/dist/web-speech-cognitive-services.mjs +126 -116
- package/dist/web-speech-cognitive-services.mjs.map +1 -1
- package/dist/web-speech-cognitive-services.production.min.js +9 -9
- package/dist/web-speech-cognitive-services.production.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as memoize_one from 'memoize-one';
|
|
2
|
-
import { SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
|
|
2
|
+
import { AudioConfig, SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
|
|
3
3
|
|
|
4
4
|
declare class SpeechSynthesisUtterance {
|
|
5
5
|
constructor(text: any);
|
|
@@ -48,7 +48,7 @@ declare class SpeechSynthesisEvent {
|
|
|
48
48
|
constructor(type: any);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
declare class _default$
|
|
51
|
+
declare class _default$2 {
|
|
52
52
|
constructor(audioContext: any);
|
|
53
53
|
audioContext: any;
|
|
54
54
|
pause(): void;
|
|
@@ -58,12 +58,12 @@ declare class _default$3 {
|
|
|
58
58
|
stop(): void;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
declare class _default$
|
|
61
|
+
declare class _default$1 {
|
|
62
62
|
constructor({ audioContext, ponyfill }: {
|
|
63
63
|
audioContext: any;
|
|
64
64
|
ponyfill: any;
|
|
65
65
|
});
|
|
66
|
-
consumer: _default$
|
|
66
|
+
consumer: _default$2 | null;
|
|
67
67
|
paused: boolean;
|
|
68
68
|
queue: any[];
|
|
69
69
|
getAudioContext: memoize_one.MemoizedFn<() => any>;
|
|
@@ -75,7 +75,42 @@ declare class _default$2 {
|
|
|
75
75
|
stop(): void;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
type Credentials = Readonly<({
|
|
79
|
+
authorizationToken: string;
|
|
80
|
+
subscriptionKey?: undefined;
|
|
81
|
+
} | {
|
|
82
|
+
authorizationToken?: undefined;
|
|
83
|
+
subscriptionKey: string;
|
|
84
|
+
}) & ({
|
|
85
|
+
customVoiceHostname?: undefined;
|
|
86
|
+
region: string;
|
|
87
|
+
speechRecognitionHostname?: undefined;
|
|
88
|
+
speechSynthesisHostname?: undefined;
|
|
89
|
+
} | {
|
|
90
|
+
customVoiceHostname: string;
|
|
91
|
+
region?: undefined;
|
|
92
|
+
speechRecognitionHostname: string;
|
|
93
|
+
speechSynthesisHostname: string;
|
|
94
|
+
})>;
|
|
95
|
+
type PatchOptionsInit = {
|
|
96
|
+
audioConfig: AudioConfig;
|
|
97
|
+
credentials?: (() => Credentials | Promise<Credentials>) | Credentials | Promise<Credentials>;
|
|
98
|
+
enableTelemetry: boolean;
|
|
99
|
+
looseEvent?: boolean | undefined;
|
|
100
|
+
looseEvents?: boolean | undefined;
|
|
101
|
+
referenceGrammars?: readonly string[] | undefined;
|
|
102
|
+
region?: string | undefined;
|
|
103
|
+
speechRecognitionEndpointId: string;
|
|
104
|
+
textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
|
|
105
|
+
} & ({
|
|
106
|
+
authorizationToken: string;
|
|
107
|
+
subscriptionKey?: undefined;
|
|
108
|
+
} | {
|
|
109
|
+
authorizationToken?: undefined;
|
|
110
|
+
subscriptionKey: string;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
declare function createSpeechRecognitionPonyfill(options: PatchOptionsInit): {};
|
|
79
114
|
|
|
80
115
|
declare class SpeechGrammarList {
|
|
81
116
|
#private;
|
|
@@ -178,7 +213,7 @@ type CreateSpeechRecognitionPonyfillFromRecognizerInit = {
|
|
|
178
213
|
createRecognizer: (lang: string) => Promise<SpeechRecognizer>;
|
|
179
214
|
enableTelemetry: boolean;
|
|
180
215
|
looseEvents: boolean;
|
|
181
|
-
referenceGrammars
|
|
216
|
+
referenceGrammars?: readonly string[] | undefined;
|
|
182
217
|
textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
|
|
183
218
|
};
|
|
184
219
|
declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognizer, enableTelemetry, looseEvents, referenceGrammars, textNormalization }: CreateSpeechRecognitionPonyfillFromRecognizerInit): {
|
|
@@ -233,7 +268,7 @@ declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognize
|
|
|
233
268
|
SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
|
|
234
269
|
};
|
|
235
270
|
|
|
236
|
-
declare function _default
|
|
271
|
+
declare function _default(options: any): {
|
|
237
272
|
speechSynthesis?: never;
|
|
238
273
|
SpeechSynthesisEvent?: never;
|
|
239
274
|
SpeechSynthesisUtterance?: never;
|
|
@@ -253,10 +288,11 @@ declare function _default$1(options: any): {
|
|
|
253
288
|
SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
|
|
254
289
|
};
|
|
255
290
|
|
|
256
|
-
|
|
257
|
-
region:
|
|
258
|
-
subscriptionKey:
|
|
259
|
-
}
|
|
291
|
+
type FetchAuthorizationTokenInit = {
|
|
292
|
+
region: string;
|
|
293
|
+
subscriptionKey: string;
|
|
294
|
+
};
|
|
295
|
+
declare function fetchAuthorizationToken({ region, subscriptionKey }: FetchAuthorizationTokenInit): Promise<string>;
|
|
260
296
|
|
|
261
297
|
declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
262
298
|
speechSynthesis?: never;
|
|
@@ -264,7 +300,7 @@ declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
|
264
300
|
SpeechSynthesisUtterance?: never;
|
|
265
301
|
} | {
|
|
266
302
|
speechSynthesis: {
|
|
267
|
-
queue: _default$
|
|
303
|
+
queue: _default$1;
|
|
268
304
|
cancel(): void;
|
|
269
305
|
getVoices(): any[];
|
|
270
306
|
onvoiceschanged: any;
|
|
@@ -278,4 +314,4 @@ declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
|
278
314
|
SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
|
|
279
315
|
};
|
|
280
316
|
|
|
281
|
-
export { createSpeechRecognitionPonyfill, createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill, _default
|
|
317
|
+
export { createSpeechRecognitionPonyfill, createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill, _default as createSpeechSynthesisPonyfill, fetchAuthorizationToken };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as memoize_one from 'memoize-one';
|
|
2
|
-
import { SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
|
|
2
|
+
import { AudioConfig, SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
|
|
3
3
|
|
|
4
4
|
declare class SpeechSynthesisUtterance {
|
|
5
5
|
constructor(text: any);
|
|
@@ -48,7 +48,7 @@ declare class SpeechSynthesisEvent {
|
|
|
48
48
|
constructor(type: any);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
declare class _default$
|
|
51
|
+
declare class _default$2 {
|
|
52
52
|
constructor(audioContext: any);
|
|
53
53
|
audioContext: any;
|
|
54
54
|
pause(): void;
|
|
@@ -58,12 +58,12 @@ declare class _default$3 {
|
|
|
58
58
|
stop(): void;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
declare class _default$
|
|
61
|
+
declare class _default$1 {
|
|
62
62
|
constructor({ audioContext, ponyfill }: {
|
|
63
63
|
audioContext: any;
|
|
64
64
|
ponyfill: any;
|
|
65
65
|
});
|
|
66
|
-
consumer: _default$
|
|
66
|
+
consumer: _default$2 | null;
|
|
67
67
|
paused: boolean;
|
|
68
68
|
queue: any[];
|
|
69
69
|
getAudioContext: memoize_one.MemoizedFn<() => any>;
|
|
@@ -75,7 +75,42 @@ declare class _default$2 {
|
|
|
75
75
|
stop(): void;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
type Credentials = Readonly<({
|
|
79
|
+
authorizationToken: string;
|
|
80
|
+
subscriptionKey?: undefined;
|
|
81
|
+
} | {
|
|
82
|
+
authorizationToken?: undefined;
|
|
83
|
+
subscriptionKey: string;
|
|
84
|
+
}) & ({
|
|
85
|
+
customVoiceHostname?: undefined;
|
|
86
|
+
region: string;
|
|
87
|
+
speechRecognitionHostname?: undefined;
|
|
88
|
+
speechSynthesisHostname?: undefined;
|
|
89
|
+
} | {
|
|
90
|
+
customVoiceHostname: string;
|
|
91
|
+
region?: undefined;
|
|
92
|
+
speechRecognitionHostname: string;
|
|
93
|
+
speechSynthesisHostname: string;
|
|
94
|
+
})>;
|
|
95
|
+
type PatchOptionsInit = {
|
|
96
|
+
audioConfig: AudioConfig;
|
|
97
|
+
credentials?: (() => Credentials | Promise<Credentials>) | Credentials | Promise<Credentials>;
|
|
98
|
+
enableTelemetry: boolean;
|
|
99
|
+
looseEvent?: boolean | undefined;
|
|
100
|
+
looseEvents?: boolean | undefined;
|
|
101
|
+
referenceGrammars?: readonly string[] | undefined;
|
|
102
|
+
region?: string | undefined;
|
|
103
|
+
speechRecognitionEndpointId: string;
|
|
104
|
+
textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
|
|
105
|
+
} & ({
|
|
106
|
+
authorizationToken: string;
|
|
107
|
+
subscriptionKey?: undefined;
|
|
108
|
+
} | {
|
|
109
|
+
authorizationToken?: undefined;
|
|
110
|
+
subscriptionKey: string;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
declare function createSpeechRecognitionPonyfill(options: PatchOptionsInit): {};
|
|
79
114
|
|
|
80
115
|
declare class SpeechGrammarList {
|
|
81
116
|
#private;
|
|
@@ -178,7 +213,7 @@ type CreateSpeechRecognitionPonyfillFromRecognizerInit = {
|
|
|
178
213
|
createRecognizer: (lang: string) => Promise<SpeechRecognizer>;
|
|
179
214
|
enableTelemetry: boolean;
|
|
180
215
|
looseEvents: boolean;
|
|
181
|
-
referenceGrammars
|
|
216
|
+
referenceGrammars?: readonly string[] | undefined;
|
|
182
217
|
textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
|
|
183
218
|
};
|
|
184
219
|
declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognizer, enableTelemetry, looseEvents, referenceGrammars, textNormalization }: CreateSpeechRecognitionPonyfillFromRecognizerInit): {
|
|
@@ -233,7 +268,7 @@ declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognize
|
|
|
233
268
|
SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
|
|
234
269
|
};
|
|
235
270
|
|
|
236
|
-
declare function _default
|
|
271
|
+
declare function _default(options: any): {
|
|
237
272
|
speechSynthesis?: never;
|
|
238
273
|
SpeechSynthesisEvent?: never;
|
|
239
274
|
SpeechSynthesisUtterance?: never;
|
|
@@ -253,10 +288,11 @@ declare function _default$1(options: any): {
|
|
|
253
288
|
SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
|
|
254
289
|
};
|
|
255
290
|
|
|
256
|
-
|
|
257
|
-
region:
|
|
258
|
-
subscriptionKey:
|
|
259
|
-
}
|
|
291
|
+
type FetchAuthorizationTokenInit = {
|
|
292
|
+
region: string;
|
|
293
|
+
subscriptionKey: string;
|
|
294
|
+
};
|
|
295
|
+
declare function fetchAuthorizationToken({ region, subscriptionKey }: FetchAuthorizationTokenInit): Promise<string>;
|
|
260
296
|
|
|
261
297
|
declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
262
298
|
speechSynthesis?: never;
|
|
@@ -264,7 +300,7 @@ declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
|
264
300
|
SpeechSynthesisUtterance?: never;
|
|
265
301
|
} | {
|
|
266
302
|
speechSynthesis: {
|
|
267
|
-
queue: _default$
|
|
303
|
+
queue: _default$1;
|
|
268
304
|
cancel(): void;
|
|
269
305
|
getVoices(): any[];
|
|
270
306
|
onvoiceschanged: any;
|
|
@@ -278,4 +314,4 @@ declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
|
278
314
|
SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
|
|
279
315
|
};
|
|
280
316
|
|
|
281
|
-
export { createSpeechRecognitionPonyfill, createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill, _default
|
|
317
|
+
export { createSpeechRecognitionPonyfill, createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill, _default as createSpeechSynthesisPonyfill, fetchAuthorizationToken };
|
|
@@ -23440,17 +23440,21 @@
|
|
|
23440
23440
|
return isFunction(fnOrValue) ? fnOrValue() : fnOrValue;
|
|
23441
23441
|
}
|
|
23442
23442
|
|
|
23443
|
-
// src/SpeechServices/patchOptions.
|
|
23443
|
+
// src/SpeechServices/patchOptions.ts
|
|
23444
23444
|
var shouldWarnOnSubscriptionKey = true;
|
|
23445
|
-
function patchOptions({
|
|
23446
|
-
|
|
23447
|
-
|
|
23448
|
-
|
|
23449
|
-
|
|
23450
|
-
|
|
23451
|
-
|
|
23452
|
-
|
|
23453
|
-
|
|
23445
|
+
function patchOptions(init) {
|
|
23446
|
+
const {
|
|
23447
|
+
audioConfig,
|
|
23448
|
+
authorizationToken,
|
|
23449
|
+
enableTelemetry,
|
|
23450
|
+
looseEvent,
|
|
23451
|
+
referenceGrammars,
|
|
23452
|
+
region = "westus",
|
|
23453
|
+
speechRecognitionEndpointId,
|
|
23454
|
+
subscriptionKey,
|
|
23455
|
+
textNormalization
|
|
23456
|
+
} = init;
|
|
23457
|
+
let { credentials, looseEvents } = init;
|
|
23454
23458
|
if (typeof looseEvent !== "undefined") {
|
|
23455
23459
|
console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".');
|
|
23456
23460
|
looseEvents = looseEvent;
|
|
@@ -23462,11 +23466,12 @@
|
|
|
23462
23466
|
console.warn(
|
|
23463
23467
|
"web-speech-cognitive-services: We are deprecating authorizationToken, region, and subscriptionKey. Please use credentials instead. The deprecated option will be removed on or after 2020-11-14."
|
|
23464
23468
|
);
|
|
23465
|
-
credentials = async () => authorizationToken ? { authorizationToken: await resolveFunctionOrReturnValue(authorizationToken), region } : { region, subscriptionKey: await resolveFunctionOrReturnValue(subscriptionKey) };
|
|
23469
|
+
credentials = async () => typeof init.authorizationToken !== "undefined" ? { authorizationToken: await resolveFunctionOrReturnValue(init.authorizationToken), region } : { region, subscriptionKey: await resolveFunctionOrReturnValue(init.subscriptionKey) };
|
|
23466
23470
|
}
|
|
23467
23471
|
}
|
|
23468
|
-
return {
|
|
23469
|
-
|
|
23472
|
+
return Object.freeze({
|
|
23473
|
+
audioConfig,
|
|
23474
|
+
enableTelemetry,
|
|
23470
23475
|
fetchCredentials: async () => {
|
|
23471
23476
|
const {
|
|
23472
23477
|
authorizationToken: authorizationToken2,
|
|
@@ -23501,21 +23506,23 @@
|
|
|
23501
23506
|
);
|
|
23502
23507
|
shouldWarnOnSubscriptionKey = false;
|
|
23503
23508
|
}
|
|
23504
|
-
|
|
23505
|
-
|
|
23506
|
-
|
|
23507
|
-
|
|
23508
|
-
|
|
23509
|
-
|
|
23510
|
-
|
|
23511
|
-
}
|
|
23512
|
-
return resolvedCredentials;
|
|
23509
|
+
return {
|
|
23510
|
+
...typeof authorizationToken2 !== "undefined" ? { authorizationToken: authorizationToken2 } : { subscriptionKey: subscriptionKey2 },
|
|
23511
|
+
...typeof region2 !== "undefined" ? { region: region2 } : {
|
|
23512
|
+
customVoiceHostname,
|
|
23513
|
+
speechRecognitionHostname,
|
|
23514
|
+
speechSynthesisHostname
|
|
23515
|
+
}
|
|
23516
|
+
};
|
|
23513
23517
|
},
|
|
23514
|
-
looseEvents
|
|
23515
|
-
|
|
23518
|
+
looseEvents: !!looseEvents,
|
|
23519
|
+
referenceGrammars: referenceGrammars && Object.freeze([...referenceGrammars]),
|
|
23520
|
+
speechRecognitionEndpointId,
|
|
23521
|
+
textNormalization
|
|
23522
|
+
});
|
|
23516
23523
|
}
|
|
23517
23524
|
|
|
23518
|
-
// src/SpeechServices/SpeechSDK.
|
|
23525
|
+
// src/SpeechServices/SpeechSDK.ts
|
|
23519
23526
|
var import_microsoft_cognitiveservices_speech = __toESM(require_microsoft_cognitiveservices_speech_sdk());
|
|
23520
23527
|
var SpeechSDK_default = {
|
|
23521
23528
|
AudioConfig: import_microsoft_cognitiveservices_speech.AudioConfig,
|
|
@@ -23652,82 +23659,6 @@
|
|
|
23652
23659
|
);
|
|
23653
23660
|
}
|
|
23654
23661
|
|
|
23655
|
-
// src/SpeechServices/SpeechToText/SpeechGrammarList.ts
|
|
23656
|
-
var SpeechGrammarList = class {
|
|
23657
|
-
constructor() {
|
|
23658
|
-
this.#phrases = [];
|
|
23659
|
-
}
|
|
23660
|
-
addFromString() {
|
|
23661
|
-
throw new Error("JSGF is not supported");
|
|
23662
|
-
}
|
|
23663
|
-
#phrases;
|
|
23664
|
-
get phrases() {
|
|
23665
|
-
return this.#phrases;
|
|
23666
|
-
}
|
|
23667
|
-
set phrases(value) {
|
|
23668
|
-
if (Array.isArray(value)) {
|
|
23669
|
-
this.#phrases = Object.freeze([...value]);
|
|
23670
|
-
} else if (typeof value === "string") {
|
|
23671
|
-
this.#phrases = Object.freeze([value]);
|
|
23672
|
-
} else {
|
|
23673
|
-
throw new Error(`The provided value is not an array or of type 'string'`);
|
|
23674
|
-
}
|
|
23675
|
-
}
|
|
23676
|
-
};
|
|
23677
|
-
|
|
23678
|
-
// src/SpeechServices/SpeechToText/SpeechRecognitionErrorEvent.ts
|
|
23679
|
-
var SpeechRecognitionErrorEvent = class extends Event {
|
|
23680
|
-
constructor(type, { error, message }) {
|
|
23681
|
-
super(type);
|
|
23682
|
-
this.#error = error;
|
|
23683
|
-
this.#message = message;
|
|
23684
|
-
}
|
|
23685
|
-
#error;
|
|
23686
|
-
#message;
|
|
23687
|
-
get error() {
|
|
23688
|
-
return this.#error;
|
|
23689
|
-
}
|
|
23690
|
-
get message() {
|
|
23691
|
-
return this.#message;
|
|
23692
|
-
}
|
|
23693
|
-
get type() {
|
|
23694
|
-
return "error";
|
|
23695
|
-
}
|
|
23696
|
-
};
|
|
23697
|
-
|
|
23698
|
-
// src/SpeechServices/SpeechToText/SpeechRecognitionResultList.ts
|
|
23699
|
-
var SpeechRecognitionResultList = class extends FakeArray {
|
|
23700
|
-
constructor(result) {
|
|
23701
|
-
super(result);
|
|
23702
|
-
}
|
|
23703
|
-
};
|
|
23704
|
-
|
|
23705
|
-
// src/SpeechServices/SpeechToText/SpeechRecognitionEvent.ts
|
|
23706
|
-
var SpeechRecognitionEvent = class extends Event {
|
|
23707
|
-
constructor(type, { data, resultIndex, results } = {}) {
|
|
23708
|
-
super(type);
|
|
23709
|
-
this.#data = data;
|
|
23710
|
-
this.#resultIndex = resultIndex;
|
|
23711
|
-
this.#results = results || new SpeechRecognitionResultList([]);
|
|
23712
|
-
}
|
|
23713
|
-
#data;
|
|
23714
|
-
// TODO: "resultIndex" should be set.
|
|
23715
|
-
#resultIndex;
|
|
23716
|
-
#results;
|
|
23717
|
-
get data() {
|
|
23718
|
-
return this.#data;
|
|
23719
|
-
}
|
|
23720
|
-
get resultIndex() {
|
|
23721
|
-
return this.#resultIndex;
|
|
23722
|
-
}
|
|
23723
|
-
get results() {
|
|
23724
|
-
return this.#results;
|
|
23725
|
-
}
|
|
23726
|
-
get type() {
|
|
23727
|
-
return super.type;
|
|
23728
|
-
}
|
|
23729
|
-
};
|
|
23730
|
-
|
|
23731
23662
|
// src/SpeechServices/SpeechToText/private/EventListenerMap.ts
|
|
23732
23663
|
var EventListenerMap = class {
|
|
23733
23664
|
constructor(eventTarget) {
|
|
@@ -23816,6 +23747,82 @@
|
|
|
23816
23747
|
});
|
|
23817
23748
|
}
|
|
23818
23749
|
|
|
23750
|
+
// src/SpeechServices/SpeechToText/SpeechGrammarList.ts
|
|
23751
|
+
var SpeechGrammarList = class {
|
|
23752
|
+
constructor() {
|
|
23753
|
+
this.#phrases = [];
|
|
23754
|
+
}
|
|
23755
|
+
addFromString() {
|
|
23756
|
+
throw new Error("JSGF is not supported");
|
|
23757
|
+
}
|
|
23758
|
+
#phrases;
|
|
23759
|
+
get phrases() {
|
|
23760
|
+
return this.#phrases;
|
|
23761
|
+
}
|
|
23762
|
+
set phrases(value) {
|
|
23763
|
+
if (Array.isArray(value)) {
|
|
23764
|
+
this.#phrases = Object.freeze([...value]);
|
|
23765
|
+
} else if (typeof value === "string") {
|
|
23766
|
+
this.#phrases = Object.freeze([value]);
|
|
23767
|
+
} else {
|
|
23768
|
+
throw new Error(`The provided value is not an array or of type 'string'`);
|
|
23769
|
+
}
|
|
23770
|
+
}
|
|
23771
|
+
};
|
|
23772
|
+
|
|
23773
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionErrorEvent.ts
|
|
23774
|
+
var SpeechRecognitionErrorEvent = class extends Event {
|
|
23775
|
+
constructor(type, { error, message }) {
|
|
23776
|
+
super(type);
|
|
23777
|
+
this.#error = error;
|
|
23778
|
+
this.#message = message;
|
|
23779
|
+
}
|
|
23780
|
+
#error;
|
|
23781
|
+
#message;
|
|
23782
|
+
get error() {
|
|
23783
|
+
return this.#error;
|
|
23784
|
+
}
|
|
23785
|
+
get message() {
|
|
23786
|
+
return this.#message;
|
|
23787
|
+
}
|
|
23788
|
+
get type() {
|
|
23789
|
+
return "error";
|
|
23790
|
+
}
|
|
23791
|
+
};
|
|
23792
|
+
|
|
23793
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionResultList.ts
|
|
23794
|
+
var SpeechRecognitionResultList = class extends FakeArray {
|
|
23795
|
+
constructor(result) {
|
|
23796
|
+
super(result);
|
|
23797
|
+
}
|
|
23798
|
+
};
|
|
23799
|
+
|
|
23800
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionEvent.ts
|
|
23801
|
+
var SpeechRecognitionEvent = class extends Event {
|
|
23802
|
+
constructor(type, { data, resultIndex, results } = {}) {
|
|
23803
|
+
super(type);
|
|
23804
|
+
this.#data = data;
|
|
23805
|
+
this.#resultIndex = resultIndex;
|
|
23806
|
+
this.#results = results || new SpeechRecognitionResultList([]);
|
|
23807
|
+
}
|
|
23808
|
+
#data;
|
|
23809
|
+
// TODO: "resultIndex" should be set.
|
|
23810
|
+
#resultIndex;
|
|
23811
|
+
#results;
|
|
23812
|
+
get data() {
|
|
23813
|
+
return this.#data;
|
|
23814
|
+
}
|
|
23815
|
+
get resultIndex() {
|
|
23816
|
+
return this.#resultIndex;
|
|
23817
|
+
}
|
|
23818
|
+
get results() {
|
|
23819
|
+
return this.#results;
|
|
23820
|
+
}
|
|
23821
|
+
get type() {
|
|
23822
|
+
return super.type;
|
|
23823
|
+
}
|
|
23824
|
+
};
|
|
23825
|
+
|
|
23819
23826
|
// src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfillFromRecognizer.ts
|
|
23820
23827
|
var { ResultReason: ResultReason2, SpeechRecognizer: SpeechRecognizer2 } = SpeechSDK_default;
|
|
23821
23828
|
function createSpeechRecognitionPonyfillFromRecognizer({
|
|
@@ -24025,7 +24032,7 @@
|
|
|
24025
24032
|
};
|
|
24026
24033
|
const { phrases } = this.grammars;
|
|
24027
24034
|
const { dynamicGrammar } = recognizer["privReco"];
|
|
24028
|
-
referenceGrammars && referenceGrammars.length && dynamicGrammar.addReferenceGrammar(referenceGrammars);
|
|
24035
|
+
referenceGrammars && referenceGrammars.length && dynamicGrammar.addReferenceGrammar([...referenceGrammars]);
|
|
24029
24036
|
phrases && phrases.length && dynamicGrammar.addPhrase([...phrases]);
|
|
24030
24037
|
await cognitiveServicesAsyncToPromise(recognizer.startContinuousRecognitionAsync, recognizer)();
|
|
24031
24038
|
if (typeof recognizer.stopContinuousRecognitionAsync === "function") {
|
|
@@ -24194,7 +24201,7 @@
|
|
|
24194
24201
|
};
|
|
24195
24202
|
}
|
|
24196
24203
|
|
|
24197
|
-
// src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.
|
|
24204
|
+
// src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.ts
|
|
24198
24205
|
var { AudioConfig: AudioConfig2, OutputFormat: OutputFormat2, SpeechConfig: SpeechConfig2, SpeechRecognizer: SpeechRecognizer3 } = SpeechSDK_default;
|
|
24199
24206
|
function createSpeechRecognitionPonyfill(options) {
|
|
24200
24207
|
const {
|
|
@@ -24215,18 +24222,19 @@
|
|
|
24215
24222
|
return {};
|
|
24216
24223
|
}
|
|
24217
24224
|
const createRecognizer = async (lang) => {
|
|
24218
|
-
const
|
|
24225
|
+
const credentials = await fetchCredentials();
|
|
24219
24226
|
let speechConfig;
|
|
24220
|
-
if (speechRecognitionHostname) {
|
|
24221
|
-
const host =
|
|
24222
|
-
|
|
24227
|
+
if (typeof credentials.speechRecognitionHostname !== "undefined") {
|
|
24228
|
+
const host = new URL("wss://hostname:443");
|
|
24229
|
+
host.hostname = credentials.speechRecognitionHostname;
|
|
24230
|
+
if (credentials.authorizationToken) {
|
|
24223
24231
|
speechConfig = SpeechConfig2.fromHost(host);
|
|
24224
|
-
speechConfig.authorizationToken = authorizationToken;
|
|
24232
|
+
speechConfig.authorizationToken = credentials.authorizationToken;
|
|
24225
24233
|
} else {
|
|
24226
|
-
speechConfig = SpeechConfig2.fromHost(host, subscriptionKey);
|
|
24234
|
+
speechConfig = SpeechConfig2.fromHost(host, credentials.subscriptionKey);
|
|
24227
24235
|
}
|
|
24228
24236
|
} else {
|
|
24229
|
-
speechConfig = authorizationToken ? SpeechConfig2.fromAuthorizationToken(authorizationToken, region) : SpeechConfig2.fromSubscription(subscriptionKey, region);
|
|
24237
|
+
speechConfig = typeof credentials.authorizationToken !== "undefined" ? SpeechConfig2.fromAuthorizationToken(credentials.authorizationToken, credentials.region) : SpeechConfig2.fromSubscription(credentials.subscriptionKey, credentials.region);
|
|
24230
24238
|
}
|
|
24231
24239
|
if (speechRecognitionEndpointId) {
|
|
24232
24240
|
speechConfig.endpointId = speechRecognitionEndpointId;
|
|
@@ -24236,7 +24244,6 @@
|
|
|
24236
24244
|
return new SpeechRecognizer3(speechConfig, audioConfig);
|
|
24237
24245
|
};
|
|
24238
24246
|
return createSpeechRecognitionPonyfillFromRecognizer({
|
|
24239
|
-
audioConfig,
|
|
24240
24247
|
createRecognizer,
|
|
24241
24248
|
enableTelemetry,
|
|
24242
24249
|
looseEvents,
|
|
@@ -24245,7 +24252,7 @@
|
|
|
24245
24252
|
});
|
|
24246
24253
|
}
|
|
24247
24254
|
|
|
24248
|
-
// src/SpeechServices/SpeechToText.
|
|
24255
|
+
// src/SpeechServices/SpeechToText.ts
|
|
24249
24256
|
var SpeechToText_default = createSpeechRecognitionPonyfill;
|
|
24250
24257
|
|
|
24251
24258
|
// ../../node_modules/event-target-shim/index.mjs
|
|
@@ -25722,7 +25729,7 @@
|
|
|
25722
25729
|
}
|
|
25723
25730
|
var meta = document.createElement("meta");
|
|
25724
25731
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
25725
|
-
meta.setAttribute("content", `version=${"8.0.0-main.
|
|
25732
|
+
meta.setAttribute("content", `version=${"8.0.0-main.d9ef940"}`);
|
|
25726
25733
|
document.head.appendChild(meta);
|
|
25727
25734
|
|
|
25728
25735
|
// src/index.umd.js
|