web-speech-cognitive-services 7.1.4-master.9e026d9 → 8.0.0-main.15b930d

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.
Files changed (100) hide show
  1. package/dist/web-speech-cognitive-services.d.mts +329 -0
  2. package/dist/web-speech-cognitive-services.d.ts +329 -0
  3. package/dist/web-speech-cognitive-services.development.js +25746 -0
  4. package/dist/web-speech-cognitive-services.development.js.map +1 -0
  5. package/dist/web-speech-cognitive-services.js +1409 -0
  6. package/dist/web-speech-cognitive-services.js.map +1 -0
  7. package/dist/web-speech-cognitive-services.mjs +1374 -0
  8. package/dist/web-speech-cognitive-services.mjs.map +1 -0
  9. package/dist/web-speech-cognitive-services.production.min.js +31 -0
  10. package/dist/web-speech-cognitive-services.production.min.js.map +1 -0
  11. package/package.json +67 -47
  12. package/CHANGELOG.md +0 -372
  13. package/lib/BingSpeech/SpeechToText/SpeechGrammarList.js +0 -94
  14. package/lib/BingSpeech/SpeechToText/SpeechGrammarList.js.map +0 -1
  15. package/lib/BingSpeech/SpeechToText/createSpeechRecognitionPonyfill.js +0 -483
  16. package/lib/BingSpeech/SpeechToText/createSpeechRecognitionPonyfill.js.map +0 -1
  17. package/lib/BingSpeech/SpeechToText.js +0 -14
  18. package/lib/BingSpeech/SpeechToText.js.map +0 -1
  19. package/lib/BingSpeech/TextToSpeech/AudioContextConsumer.js +0 -122
  20. package/lib/BingSpeech/TextToSpeech/AudioContextConsumer.js.map +0 -1
  21. package/lib/BingSpeech/TextToSpeech/AudioContextQueue.js +0 -104
  22. package/lib/BingSpeech/TextToSpeech/AudioContextQueue.js.map +0 -1
  23. package/lib/BingSpeech/TextToSpeech/SpeechSynthesisUtterance.js +0 -264
  24. package/lib/BingSpeech/TextToSpeech/SpeechSynthesisUtterance.js.map +0 -1
  25. package/lib/BingSpeech/TextToSpeech/SpeechSynthesisVoice.js +0 -61
  26. package/lib/BingSpeech/TextToSpeech/SpeechSynthesisVoice.js.map +0 -1
  27. package/lib/BingSpeech/TextToSpeech/buildSSML.js +0 -32
  28. package/lib/BingSpeech/TextToSpeech/buildSSML.js.map +0 -1
  29. package/lib/BingSpeech/TextToSpeech/createSpeechSynthesisPonyfill.js +0 -220
  30. package/lib/BingSpeech/TextToSpeech/createSpeechSynthesisPonyfill.js.map +0 -1
  31. package/lib/BingSpeech/TextToSpeech/fetchSpeechData.js +0 -74
  32. package/lib/BingSpeech/TextToSpeech/fetchSpeechData.js.map +0 -1
  33. package/lib/BingSpeech/TextToSpeech/fetchVoices.js +0 -335
  34. package/lib/BingSpeech/TextToSpeech/fetchVoices.js.map +0 -1
  35. package/lib/BingSpeech/TextToSpeech/isSSML.js +0 -13
  36. package/lib/BingSpeech/TextToSpeech/isSSML.js.map +0 -1
  37. package/lib/BingSpeech/TextToSpeech/subscribeEvent.js +0 -14
  38. package/lib/BingSpeech/TextToSpeech/subscribeEvent.js.map +0 -1
  39. package/lib/BingSpeech/TextToSpeech.js +0 -14
  40. package/lib/BingSpeech/TextToSpeech.js.map +0 -1
  41. package/lib/BingSpeech/Util/DOMEventEmitter.js +0 -61
  42. package/lib/BingSpeech/Util/DOMEventEmitter.js.map +0 -1
  43. package/lib/BingSpeech/Util/createFetchTokenUsingSubscriptionKey.js +0 -41
  44. package/lib/BingSpeech/Util/createFetchTokenUsingSubscriptionKey.js.map +0 -1
  45. package/lib/BingSpeech/fetchAuthorizationToken.js +0 -57
  46. package/lib/BingSpeech/fetchAuthorizationToken.js.map +0 -1
  47. package/lib/BingSpeech/index.js +0 -84
  48. package/lib/BingSpeech/index.js.map +0 -1
  49. package/lib/SpeechServices/SpeechSDK.js +0 -19
  50. package/lib/SpeechServices/SpeechSDK.js.map +0 -1
  51. package/lib/SpeechServices/SpeechToText/SpeechGrammarList.js +0 -45
  52. package/lib/SpeechServices/SpeechToText/SpeechGrammarList.js.map +0 -1
  53. package/lib/SpeechServices/SpeechToText/cognitiveServiceEventResultToWebSpeechRecognitionResultList.js +0 -56
  54. package/lib/SpeechServices/SpeechToText/cognitiveServiceEventResultToWebSpeechRecognitionResultList.js.map +0 -1
  55. package/lib/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.js +0 -984
  56. package/lib/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.js.map +0 -1
  57. package/lib/SpeechServices/SpeechToText.js +0 -24
  58. package/lib/SpeechServices/SpeechToText.js.map +0 -1
  59. package/lib/SpeechServices/TextToSpeech/AudioContextConsumer.js +0 -92
  60. package/lib/SpeechServices/TextToSpeech/AudioContextConsumer.js.map +0 -1
  61. package/lib/SpeechServices/TextToSpeech/AudioContextQueue.js +0 -111
  62. package/lib/SpeechServices/TextToSpeech/AudioContextQueue.js.map +0 -1
  63. package/lib/SpeechServices/TextToSpeech/SpeechSynthesisEvent.js +0 -40
  64. package/lib/SpeechServices/TextToSpeech/SpeechSynthesisEvent.js.map +0 -1
  65. package/lib/SpeechServices/TextToSpeech/SpeechSynthesisUtterance.js +0 -283
  66. package/lib/SpeechServices/TextToSpeech/SpeechSynthesisUtterance.js.map +0 -1
  67. package/lib/SpeechServices/TextToSpeech/SpeechSynthesisVoice.js +0 -63
  68. package/lib/SpeechServices/TextToSpeech/SpeechSynthesisVoice.js.map +0 -1
  69. package/lib/SpeechServices/TextToSpeech/buildSSML.js +0 -32
  70. package/lib/SpeechServices/TextToSpeech/buildSSML.js.map +0 -1
  71. package/lib/SpeechServices/TextToSpeech/createSpeechSynthesisPonyfill.js +0 -282
  72. package/lib/SpeechServices/TextToSpeech/createSpeechSynthesisPonyfill.js.map +0 -1
  73. package/lib/SpeechServices/TextToSpeech/fetchCustomVoices.js +0 -110
  74. package/lib/SpeechServices/TextToSpeech/fetchCustomVoices.js.map +0 -1
  75. package/lib/SpeechServices/TextToSpeech/fetchSpeechData.js +0 -127
  76. package/lib/SpeechServices/TextToSpeech/fetchSpeechData.js.map +0 -1
  77. package/lib/SpeechServices/TextToSpeech/fetchVoices.js +0 -87
  78. package/lib/SpeechServices/TextToSpeech/fetchVoices.js.map +0 -1
  79. package/lib/SpeechServices/TextToSpeech/isSSML.js +0 -13
  80. package/lib/SpeechServices/TextToSpeech/isSSML.js.map +0 -1
  81. package/lib/SpeechServices/TextToSpeech/subscribeEvent.js +0 -14
  82. package/lib/SpeechServices/TextToSpeech/subscribeEvent.js.map +0 -1
  83. package/lib/SpeechServices/TextToSpeech.js +0 -14
  84. package/lib/SpeechServices/TextToSpeech.js.map +0 -1
  85. package/lib/SpeechServices/fetchAuthorizationToken.js +0 -58
  86. package/lib/SpeechServices/fetchAuthorizationToken.js.map +0 -1
  87. package/lib/SpeechServices/patchOptions.js +0 -213
  88. package/lib/SpeechServices/patchOptions.js.map +0 -1
  89. package/lib/SpeechServices/resolveFunctionOrReturnValue.js +0 -11
  90. package/lib/SpeechServices/resolveFunctionOrReturnValue.js.map +0 -1
  91. package/lib/SpeechServices.js +0 -73
  92. package/lib/SpeechServices.js.map +0 -1
  93. package/lib/Util/arrayToMap.js +0 -28
  94. package/lib/Util/arrayToMap.js.map +0 -1
  95. package/lib/Util/createPromiseQueue.js +0 -40
  96. package/lib/Util/createPromiseQueue.js.map +0 -1
  97. package/lib/index.js +0 -14
  98. package/lib/index.js.map +0 -1
  99. package/umd/web-speech-cognitive-services.development.js +0 -4740
  100. package/umd/web-speech-cognitive-services.production.min.js +0 -2
@@ -0,0 +1,329 @@
1
+ import { AudioConfig, SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
2
+
3
+ type SpeechRecognitionErrorType = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed' | 'unknown';
4
+ type SpeechRecognitionErrorEventInit = {
5
+ error: SpeechRecognitionErrorType;
6
+ message?: string | undefined;
7
+ };
8
+ declare class SpeechRecognitionErrorEvent extends Event {
9
+ #private;
10
+ constructor(type: 'error', { error, message }: SpeechRecognitionErrorEventInit);
11
+ get error(): SpeechRecognitionErrorType;
12
+ get message(): string | undefined;
13
+ get type(): 'error';
14
+ }
15
+
16
+ interface FakeArrayInterface<T> {
17
+ [index: number]: T | undefined;
18
+ get length(): number;
19
+ }
20
+ declare class FakeArray<T> implements FakeArrayInterface<T> {
21
+ #private;
22
+ constructor(array: readonly T[]);
23
+ [index: number]: T | undefined;
24
+ [Symbol.iterator](): IterableIterator<T>;
25
+ get length(): number;
26
+ }
27
+
28
+ type SpeechRecognitionResultInit = {
29
+ isFinal: boolean;
30
+ results: readonly SpeechRecognitionAlternative[];
31
+ };
32
+ declare class SpeechRecognitionResult extends FakeArray<SpeechRecognitionAlternative> {
33
+ #private;
34
+ constructor(init: SpeechRecognitionResultInit);
35
+ get isFinal(): boolean;
36
+ }
37
+
38
+ declare class SpeechRecognitionResultList extends FakeArray<SpeechRecognitionResult> {
39
+ constructor(result: readonly SpeechRecognitionResult[]);
40
+ }
41
+
42
+ type SpeechRecognitionEventInit = {
43
+ data?: undefined | unknown;
44
+ resultIndex?: number | undefined;
45
+ results?: SpeechRecognitionResultList | undefined;
46
+ };
47
+ declare class SpeechRecognitionEvent<T extends 'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start'> extends Event {
48
+ #private;
49
+ constructor(type: 'cognitiveservices', init: SpeechRecognitionEventInit & {
50
+ data: {
51
+ type: string;
52
+ };
53
+ });
54
+ constructor(type: 'audioend');
55
+ constructor(type: 'audiostart');
56
+ constructor(type: 'end');
57
+ constructor(type: 'result', init: SpeechRecognitionEventInit);
58
+ constructor(type: 'soundend');
59
+ constructor(type: 'soundstart');
60
+ constructor(type: 'speechend');
61
+ constructor(type: 'speechstart');
62
+ constructor(type: 'start');
63
+ get data(): unknown;
64
+ get resultIndex(): number | undefined;
65
+ get results(): SpeechRecognitionResultList;
66
+ get type(): T;
67
+ }
68
+
69
+ declare class EventListenerMap<T extends string, EventMap extends {
70
+ [Name in T]: unknown;
71
+ }> {
72
+ #private;
73
+ constructor(eventTarget: EventTarget);
74
+ getProperty<U extends T>(name: U): ((event: EventMap[U]) => void) | undefined;
75
+ setProperty<U extends T>(name: U, value: ((event: EventMap[U]) => void) | undefined): void;
76
+ }
77
+
78
+ type SpeechRecognitionEventListenerMap = EventListenerMap<'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'error' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start', {
79
+ audioend: SpeechRecognitionEvent<'audioend'>;
80
+ audiostart: SpeechRecognitionEvent<'audiostart'>;
81
+ cognitiveservices: SpeechRecognitionEvent<'cognitiveservices'>;
82
+ end: SpeechRecognitionEvent<'end'>;
83
+ error: SpeechRecognitionErrorEvent;
84
+ result: SpeechRecognitionEvent<'result'>;
85
+ soundend: SpeechRecognitionEvent<'soundend'>;
86
+ soundstart: SpeechRecognitionEvent<'soundstart'>;
87
+ speechend: SpeechRecognitionEvent<'speechend'>;
88
+ speechstart: SpeechRecognitionEvent<'speechstart'>;
89
+ start: SpeechRecognitionEvent<'start'>;
90
+ }>;
91
+
92
+ interface W3CSpeechGrammar {
93
+ src: string;
94
+ weight: number;
95
+ }
96
+ interface W3CSpeechGrammarList {
97
+ readonly length: number;
98
+ addFromString(string: string, weight?: number): void;
99
+ addFromURI(src: string, weight?: number): void;
100
+ item(index: number): W3CSpeechGrammar;
101
+ [index: number]: W3CSpeechGrammar;
102
+ }
103
+ declare class SpeechGrammarList implements W3CSpeechGrammarList {
104
+ #private;
105
+ constructor();
106
+ addFromString(): void;
107
+ addFromURI(): void;
108
+ item(): W3CSpeechGrammar;
109
+ get length(): number;
110
+ [index: number]: {
111
+ src: string;
112
+ weight: number;
113
+ };
114
+ get phrases(): readonly string[];
115
+ set phrases(value: readonly string[]);
116
+ }
117
+
118
+ type Credentials = Readonly<({
119
+ authorizationToken: string;
120
+ subscriptionKey?: undefined;
121
+ } | {
122
+ authorizationToken?: undefined;
123
+ subscriptionKey: string;
124
+ }) & ({
125
+ customVoiceHostname?: undefined;
126
+ region: string;
127
+ speechRecognitionHostname?: undefined;
128
+ speechSynthesisHostname?: undefined;
129
+ } | {
130
+ customVoiceHostname: string;
131
+ region?: undefined;
132
+ speechRecognitionHostname: string;
133
+ speechSynthesisHostname: string;
134
+ })>;
135
+ type PatchOptionsInit = {
136
+ audioConfig: AudioConfig;
137
+ credentials?: (() => Credentials | Promise<Credentials>) | Credentials | Promise<Credentials>;
138
+ enableTelemetry: boolean;
139
+ looseEvent?: boolean | undefined;
140
+ looseEvents?: boolean | undefined;
141
+ referenceGrammars?: readonly string[] | undefined;
142
+ region?: string | undefined;
143
+ speechRecognitionEndpointId: string;
144
+ textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
145
+ } & ({
146
+ authorizationToken: string;
147
+ subscriptionKey?: undefined;
148
+ } | {
149
+ authorizationToken?: undefined;
150
+ subscriptionKey: string;
151
+ });
152
+
153
+ declare function createSpeechRecognitionPonyfill(options: PatchOptionsInit): {
154
+ SpeechGrammarList: typeof SpeechGrammarList;
155
+ SpeechRecognition: {
156
+ new (): {
157
+ "__#8@#continuous": boolean;
158
+ "__#8@#eventListenerMap": SpeechRecognitionEventListenerMap;
159
+ "__#8@#grammars": SpeechGrammarList;
160
+ "__#8@#interimResults": boolean;
161
+ "__#8@#lang": string;
162
+ "__#8@#maxAlternatives": number;
163
+ emitCognitiveServices<T extends {
164
+ type: string;
165
+ }>(type: string, event: T): void;
166
+ continuous: boolean;
167
+ grammars: SpeechGrammarList;
168
+ interimResults: boolean;
169
+ maxAlternatives: number;
170
+ lang: string;
171
+ get onaudioend(): ((event: SpeechRecognitionEvent<"audioend">) => void) | undefined;
172
+ set onaudioend(value: ((event: SpeechRecognitionEvent<"audioend">) => void) | undefined);
173
+ onaudiostart: ((event: SpeechRecognitionEvent<"audiostart">) => void) | undefined;
174
+ oncognitiveservices: ((event: SpeechRecognitionEvent<"cognitiveservices">) => void) | undefined;
175
+ onend: ((event: SpeechRecognitionEvent<"end">) => void) | undefined;
176
+ onerror: ((event: SpeechRecognitionErrorEvent) => void) | undefined;
177
+ onresult: ((event: SpeechRecognitionEvent<"result">) => void) | undefined;
178
+ onsoundend: ((event: SpeechRecognitionEvent<"soundend">) => void) | undefined;
179
+ onsoundstart: ((event: SpeechRecognitionEvent<"soundstart">) => void) | undefined;
180
+ onspeechend: ((event: SpeechRecognitionEvent<"speechend">) => void) | undefined;
181
+ onspeechstart: ((event: SpeechRecognitionEvent<"speechstart">) => void) | undefined;
182
+ onstart: ((event: SpeechRecognitionEvent<"start">) => void) | undefined;
183
+ abort: (() => void) | undefined;
184
+ stop: (() => void) | undefined;
185
+ start(): void;
186
+ _startOnce(): Promise<void>;
187
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
188
+ dispatchEvent(event: Event): boolean;
189
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void;
190
+ };
191
+ };
192
+ SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
193
+ };
194
+
195
+ type CreateSpeechRecognitionPonyfillFromRecognizerInit = {
196
+ createRecognizer: (lang: string) => Promise<SpeechRecognizer>;
197
+ enableTelemetry: boolean;
198
+ looseEvents: boolean;
199
+ referenceGrammars?: readonly string[] | undefined;
200
+ textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
201
+ };
202
+ declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognizer, enableTelemetry, looseEvents, referenceGrammars, textNormalization }: CreateSpeechRecognitionPonyfillFromRecognizerInit): {
203
+ SpeechGrammarList: typeof SpeechGrammarList;
204
+ SpeechRecognition: {
205
+ new (): {
206
+ "__#8@#continuous": boolean;
207
+ "__#8@#eventListenerMap": SpeechRecognitionEventListenerMap;
208
+ "__#8@#grammars": SpeechGrammarList;
209
+ "__#8@#interimResults": boolean;
210
+ "__#8@#lang": string;
211
+ "__#8@#maxAlternatives": number;
212
+ emitCognitiveServices<T extends {
213
+ type: string;
214
+ }>(type: string, event: T): void;
215
+ continuous: boolean;
216
+ grammars: SpeechGrammarList;
217
+ interimResults: boolean;
218
+ maxAlternatives: number;
219
+ lang: string;
220
+ get onaudioend(): ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined;
221
+ set onaudioend(value: ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined);
222
+ /** @type { ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined } */
223
+ onaudiostart: ((event: SpeechRecognitionEvent<"audiostart">) => void) | undefined;
224
+ /** @type { ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined } */
225
+ oncognitiveservices: ((event: SpeechRecognitionEvent<"cognitiveservices">) => void) | undefined;
226
+ /** @type { ((event: SpeechRecognitionEvent<'end'>) => void) | undefined } */
227
+ onend: ((event: SpeechRecognitionEvent<"end">) => void) | undefined;
228
+ /** @type { ((event: SpeechRecognitionErrorEvent) => void) | undefined } */
229
+ onerror: ((event: SpeechRecognitionErrorEvent) => void) | undefined;
230
+ /** @type { ((event: SpeechRecognitionEvent<'result'>) => void) | undefined } */
231
+ onresult: ((event: SpeechRecognitionEvent<"result">) => void) | undefined;
232
+ /** @type { ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined } */
233
+ onsoundend: ((event: SpeechRecognitionEvent<"soundend">) => void) | undefined;
234
+ /** @type { ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined } */
235
+ onsoundstart: ((event: SpeechRecognitionEvent<"soundstart">) => void) | undefined;
236
+ /** @type { ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined } */
237
+ onspeechend: ((event: SpeechRecognitionEvent<"speechend">) => void) | undefined;
238
+ /** @type { ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined } */
239
+ onspeechstart: ((event: SpeechRecognitionEvent<"speechstart">) => void) | undefined;
240
+ /** @type { ((event: SpeechRecognitionEvent<'start'>) => void) | undefined } */
241
+ onstart: ((event: SpeechRecognitionEvent<"start">) => void) | undefined;
242
+ abort: (() => void) | undefined;
243
+ stop: (() => void) | undefined;
244
+ start(): void;
245
+ _startOnce(): Promise<void>;
246
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
247
+ dispatchEvent(event: Event): boolean;
248
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void;
249
+ };
250
+ };
251
+ SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
252
+ };
253
+
254
+ declare class SpeechSynthesisEvent {
255
+ constructor(type: any);
256
+ }
257
+
258
+ declare class SpeechSynthesisUtterance {
259
+ constructor(text: any);
260
+ _lang: any;
261
+ _pitch: number;
262
+ _rate: number;
263
+ _voice: any;
264
+ _volume: number;
265
+ text: any;
266
+ set onboundary(value: any);
267
+ get onboundary(): any;
268
+ set onend(value: any);
269
+ get onend(): any;
270
+ set onerror(value: any);
271
+ get onerror(): any;
272
+ set onmark(value: any);
273
+ get onmark(): any;
274
+ set onpause(value: any);
275
+ get onpause(): any;
276
+ set onresume(value: any);
277
+ get onresume(): any;
278
+ set onstart(value: any);
279
+ get onstart(): any;
280
+ set lang(value: any);
281
+ get lang(): any;
282
+ set pitch(value: number);
283
+ get pitch(): number;
284
+ set rate(value: number);
285
+ get rate(): number;
286
+ set voice(value: any);
287
+ get voice(): any;
288
+ set volume(value: number);
289
+ get volume(): number;
290
+ preload({ deploymentId, fetchCredentials, outputFormat }: {
291
+ deploymentId: any;
292
+ fetchCredentials: any;
293
+ outputFormat: any;
294
+ }): void;
295
+ arrayBufferPromise: Promise<ArrayBuffer> | undefined;
296
+ play(audioContext: any): Promise<void>;
297
+ _playingSource: any;
298
+ stop(): void;
299
+ }
300
+
301
+ declare function _default(options: any): {
302
+ speechSynthesis?: never;
303
+ SpeechSynthesisEvent?: never;
304
+ SpeechSynthesisUtterance?: never;
305
+ } | {
306
+ speechSynthesis: {
307
+ queue: AudioContextQueue;
308
+ cancel(): void;
309
+ getVoices(): any[];
310
+ onvoiceschanged: any;
311
+ pause(): void;
312
+ resume(): void;
313
+ speak(utterance: any): Promise<any>;
314
+ readonly speaking: boolean;
315
+ updateVoices(): Promise<void>;
316
+ };
317
+ SpeechSynthesisEvent: typeof SpeechSynthesisEvent;
318
+ SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
319
+ };
320
+
321
+ type FetchAuthorizationTokenInit = {
322
+ region: string;
323
+ subscriptionKey: string;
324
+ };
325
+ declare function fetchAuthorizationToken({ region, subscriptionKey }: FetchAuthorizationTokenInit): Promise<string>;
326
+
327
+ declare function createSpeechServicesPonyfill(options?: any): any;
328
+
329
+ export { createSpeechRecognitionPonyfill, createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill, _default as createSpeechSynthesisPonyfill, fetchAuthorizationToken };
@@ -0,0 +1,329 @@
1
+ import { AudioConfig, SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
2
+
3
+ type SpeechRecognitionErrorType = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed' | 'unknown';
4
+ type SpeechRecognitionErrorEventInit = {
5
+ error: SpeechRecognitionErrorType;
6
+ message?: string | undefined;
7
+ };
8
+ declare class SpeechRecognitionErrorEvent extends Event {
9
+ #private;
10
+ constructor(type: 'error', { error, message }: SpeechRecognitionErrorEventInit);
11
+ get error(): SpeechRecognitionErrorType;
12
+ get message(): string | undefined;
13
+ get type(): 'error';
14
+ }
15
+
16
+ interface FakeArrayInterface<T> {
17
+ [index: number]: T | undefined;
18
+ get length(): number;
19
+ }
20
+ declare class FakeArray<T> implements FakeArrayInterface<T> {
21
+ #private;
22
+ constructor(array: readonly T[]);
23
+ [index: number]: T | undefined;
24
+ [Symbol.iterator](): IterableIterator<T>;
25
+ get length(): number;
26
+ }
27
+
28
+ type SpeechRecognitionResultInit = {
29
+ isFinal: boolean;
30
+ results: readonly SpeechRecognitionAlternative[];
31
+ };
32
+ declare class SpeechRecognitionResult extends FakeArray<SpeechRecognitionAlternative> {
33
+ #private;
34
+ constructor(init: SpeechRecognitionResultInit);
35
+ get isFinal(): boolean;
36
+ }
37
+
38
+ declare class SpeechRecognitionResultList extends FakeArray<SpeechRecognitionResult> {
39
+ constructor(result: readonly SpeechRecognitionResult[]);
40
+ }
41
+
42
+ type SpeechRecognitionEventInit = {
43
+ data?: undefined | unknown;
44
+ resultIndex?: number | undefined;
45
+ results?: SpeechRecognitionResultList | undefined;
46
+ };
47
+ declare class SpeechRecognitionEvent<T extends 'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start'> extends Event {
48
+ #private;
49
+ constructor(type: 'cognitiveservices', init: SpeechRecognitionEventInit & {
50
+ data: {
51
+ type: string;
52
+ };
53
+ });
54
+ constructor(type: 'audioend');
55
+ constructor(type: 'audiostart');
56
+ constructor(type: 'end');
57
+ constructor(type: 'result', init: SpeechRecognitionEventInit);
58
+ constructor(type: 'soundend');
59
+ constructor(type: 'soundstart');
60
+ constructor(type: 'speechend');
61
+ constructor(type: 'speechstart');
62
+ constructor(type: 'start');
63
+ get data(): unknown;
64
+ get resultIndex(): number | undefined;
65
+ get results(): SpeechRecognitionResultList;
66
+ get type(): T;
67
+ }
68
+
69
+ declare class EventListenerMap<T extends string, EventMap extends {
70
+ [Name in T]: unknown;
71
+ }> {
72
+ #private;
73
+ constructor(eventTarget: EventTarget);
74
+ getProperty<U extends T>(name: U): ((event: EventMap[U]) => void) | undefined;
75
+ setProperty<U extends T>(name: U, value: ((event: EventMap[U]) => void) | undefined): void;
76
+ }
77
+
78
+ type SpeechRecognitionEventListenerMap = EventListenerMap<'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'error' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start', {
79
+ audioend: SpeechRecognitionEvent<'audioend'>;
80
+ audiostart: SpeechRecognitionEvent<'audiostart'>;
81
+ cognitiveservices: SpeechRecognitionEvent<'cognitiveservices'>;
82
+ end: SpeechRecognitionEvent<'end'>;
83
+ error: SpeechRecognitionErrorEvent;
84
+ result: SpeechRecognitionEvent<'result'>;
85
+ soundend: SpeechRecognitionEvent<'soundend'>;
86
+ soundstart: SpeechRecognitionEvent<'soundstart'>;
87
+ speechend: SpeechRecognitionEvent<'speechend'>;
88
+ speechstart: SpeechRecognitionEvent<'speechstart'>;
89
+ start: SpeechRecognitionEvent<'start'>;
90
+ }>;
91
+
92
+ interface W3CSpeechGrammar {
93
+ src: string;
94
+ weight: number;
95
+ }
96
+ interface W3CSpeechGrammarList {
97
+ readonly length: number;
98
+ addFromString(string: string, weight?: number): void;
99
+ addFromURI(src: string, weight?: number): void;
100
+ item(index: number): W3CSpeechGrammar;
101
+ [index: number]: W3CSpeechGrammar;
102
+ }
103
+ declare class SpeechGrammarList implements W3CSpeechGrammarList {
104
+ #private;
105
+ constructor();
106
+ addFromString(): void;
107
+ addFromURI(): void;
108
+ item(): W3CSpeechGrammar;
109
+ get length(): number;
110
+ [index: number]: {
111
+ src: string;
112
+ weight: number;
113
+ };
114
+ get phrases(): readonly string[];
115
+ set phrases(value: readonly string[]);
116
+ }
117
+
118
+ type Credentials = Readonly<({
119
+ authorizationToken: string;
120
+ subscriptionKey?: undefined;
121
+ } | {
122
+ authorizationToken?: undefined;
123
+ subscriptionKey: string;
124
+ }) & ({
125
+ customVoiceHostname?: undefined;
126
+ region: string;
127
+ speechRecognitionHostname?: undefined;
128
+ speechSynthesisHostname?: undefined;
129
+ } | {
130
+ customVoiceHostname: string;
131
+ region?: undefined;
132
+ speechRecognitionHostname: string;
133
+ speechSynthesisHostname: string;
134
+ })>;
135
+ type PatchOptionsInit = {
136
+ audioConfig: AudioConfig;
137
+ credentials?: (() => Credentials | Promise<Credentials>) | Credentials | Promise<Credentials>;
138
+ enableTelemetry: boolean;
139
+ looseEvent?: boolean | undefined;
140
+ looseEvents?: boolean | undefined;
141
+ referenceGrammars?: readonly string[] | undefined;
142
+ region?: string | undefined;
143
+ speechRecognitionEndpointId: string;
144
+ textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
145
+ } & ({
146
+ authorizationToken: string;
147
+ subscriptionKey?: undefined;
148
+ } | {
149
+ authorizationToken?: undefined;
150
+ subscriptionKey: string;
151
+ });
152
+
153
+ declare function createSpeechRecognitionPonyfill(options: PatchOptionsInit): {
154
+ SpeechGrammarList: typeof SpeechGrammarList;
155
+ SpeechRecognition: {
156
+ new (): {
157
+ "__#8@#continuous": boolean;
158
+ "__#8@#eventListenerMap": SpeechRecognitionEventListenerMap;
159
+ "__#8@#grammars": SpeechGrammarList;
160
+ "__#8@#interimResults": boolean;
161
+ "__#8@#lang": string;
162
+ "__#8@#maxAlternatives": number;
163
+ emitCognitiveServices<T extends {
164
+ type: string;
165
+ }>(type: string, event: T): void;
166
+ continuous: boolean;
167
+ grammars: SpeechGrammarList;
168
+ interimResults: boolean;
169
+ maxAlternatives: number;
170
+ lang: string;
171
+ get onaudioend(): ((event: SpeechRecognitionEvent<"audioend">) => void) | undefined;
172
+ set onaudioend(value: ((event: SpeechRecognitionEvent<"audioend">) => void) | undefined);
173
+ onaudiostart: ((event: SpeechRecognitionEvent<"audiostart">) => void) | undefined;
174
+ oncognitiveservices: ((event: SpeechRecognitionEvent<"cognitiveservices">) => void) | undefined;
175
+ onend: ((event: SpeechRecognitionEvent<"end">) => void) | undefined;
176
+ onerror: ((event: SpeechRecognitionErrorEvent) => void) | undefined;
177
+ onresult: ((event: SpeechRecognitionEvent<"result">) => void) | undefined;
178
+ onsoundend: ((event: SpeechRecognitionEvent<"soundend">) => void) | undefined;
179
+ onsoundstart: ((event: SpeechRecognitionEvent<"soundstart">) => void) | undefined;
180
+ onspeechend: ((event: SpeechRecognitionEvent<"speechend">) => void) | undefined;
181
+ onspeechstart: ((event: SpeechRecognitionEvent<"speechstart">) => void) | undefined;
182
+ onstart: ((event: SpeechRecognitionEvent<"start">) => void) | undefined;
183
+ abort: (() => void) | undefined;
184
+ stop: (() => void) | undefined;
185
+ start(): void;
186
+ _startOnce(): Promise<void>;
187
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
188
+ dispatchEvent(event: Event): boolean;
189
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void;
190
+ };
191
+ };
192
+ SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
193
+ };
194
+
195
+ type CreateSpeechRecognitionPonyfillFromRecognizerInit = {
196
+ createRecognizer: (lang: string) => Promise<SpeechRecognizer>;
197
+ enableTelemetry: boolean;
198
+ looseEvents: boolean;
199
+ referenceGrammars?: readonly string[] | undefined;
200
+ textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
201
+ };
202
+ declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognizer, enableTelemetry, looseEvents, referenceGrammars, textNormalization }: CreateSpeechRecognitionPonyfillFromRecognizerInit): {
203
+ SpeechGrammarList: typeof SpeechGrammarList;
204
+ SpeechRecognition: {
205
+ new (): {
206
+ "__#8@#continuous": boolean;
207
+ "__#8@#eventListenerMap": SpeechRecognitionEventListenerMap;
208
+ "__#8@#grammars": SpeechGrammarList;
209
+ "__#8@#interimResults": boolean;
210
+ "__#8@#lang": string;
211
+ "__#8@#maxAlternatives": number;
212
+ emitCognitiveServices<T extends {
213
+ type: string;
214
+ }>(type: string, event: T): void;
215
+ continuous: boolean;
216
+ grammars: SpeechGrammarList;
217
+ interimResults: boolean;
218
+ maxAlternatives: number;
219
+ lang: string;
220
+ get onaudioend(): ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined;
221
+ set onaudioend(value: ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined);
222
+ /** @type { ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined } */
223
+ onaudiostart: ((event: SpeechRecognitionEvent<"audiostart">) => void) | undefined;
224
+ /** @type { ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined } */
225
+ oncognitiveservices: ((event: SpeechRecognitionEvent<"cognitiveservices">) => void) | undefined;
226
+ /** @type { ((event: SpeechRecognitionEvent<'end'>) => void) | undefined } */
227
+ onend: ((event: SpeechRecognitionEvent<"end">) => void) | undefined;
228
+ /** @type { ((event: SpeechRecognitionErrorEvent) => void) | undefined } */
229
+ onerror: ((event: SpeechRecognitionErrorEvent) => void) | undefined;
230
+ /** @type { ((event: SpeechRecognitionEvent<'result'>) => void) | undefined } */
231
+ onresult: ((event: SpeechRecognitionEvent<"result">) => void) | undefined;
232
+ /** @type { ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined } */
233
+ onsoundend: ((event: SpeechRecognitionEvent<"soundend">) => void) | undefined;
234
+ /** @type { ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined } */
235
+ onsoundstart: ((event: SpeechRecognitionEvent<"soundstart">) => void) | undefined;
236
+ /** @type { ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined } */
237
+ onspeechend: ((event: SpeechRecognitionEvent<"speechend">) => void) | undefined;
238
+ /** @type { ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined } */
239
+ onspeechstart: ((event: SpeechRecognitionEvent<"speechstart">) => void) | undefined;
240
+ /** @type { ((event: SpeechRecognitionEvent<'start'>) => void) | undefined } */
241
+ onstart: ((event: SpeechRecognitionEvent<"start">) => void) | undefined;
242
+ abort: (() => void) | undefined;
243
+ stop: (() => void) | undefined;
244
+ start(): void;
245
+ _startOnce(): Promise<void>;
246
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
247
+ dispatchEvent(event: Event): boolean;
248
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void;
249
+ };
250
+ };
251
+ SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
252
+ };
253
+
254
+ declare class SpeechSynthesisEvent {
255
+ constructor(type: any);
256
+ }
257
+
258
+ declare class SpeechSynthesisUtterance {
259
+ constructor(text: any);
260
+ _lang: any;
261
+ _pitch: number;
262
+ _rate: number;
263
+ _voice: any;
264
+ _volume: number;
265
+ text: any;
266
+ set onboundary(value: any);
267
+ get onboundary(): any;
268
+ set onend(value: any);
269
+ get onend(): any;
270
+ set onerror(value: any);
271
+ get onerror(): any;
272
+ set onmark(value: any);
273
+ get onmark(): any;
274
+ set onpause(value: any);
275
+ get onpause(): any;
276
+ set onresume(value: any);
277
+ get onresume(): any;
278
+ set onstart(value: any);
279
+ get onstart(): any;
280
+ set lang(value: any);
281
+ get lang(): any;
282
+ set pitch(value: number);
283
+ get pitch(): number;
284
+ set rate(value: number);
285
+ get rate(): number;
286
+ set voice(value: any);
287
+ get voice(): any;
288
+ set volume(value: number);
289
+ get volume(): number;
290
+ preload({ deploymentId, fetchCredentials, outputFormat }: {
291
+ deploymentId: any;
292
+ fetchCredentials: any;
293
+ outputFormat: any;
294
+ }): void;
295
+ arrayBufferPromise: Promise<ArrayBuffer> | undefined;
296
+ play(audioContext: any): Promise<void>;
297
+ _playingSource: any;
298
+ stop(): void;
299
+ }
300
+
301
+ declare function _default(options: any): {
302
+ speechSynthesis?: never;
303
+ SpeechSynthesisEvent?: never;
304
+ SpeechSynthesisUtterance?: never;
305
+ } | {
306
+ speechSynthesis: {
307
+ queue: AudioContextQueue;
308
+ cancel(): void;
309
+ getVoices(): any[];
310
+ onvoiceschanged: any;
311
+ pause(): void;
312
+ resume(): void;
313
+ speak(utterance: any): Promise<any>;
314
+ readonly speaking: boolean;
315
+ updateVoices(): Promise<void>;
316
+ };
317
+ SpeechSynthesisEvent: typeof SpeechSynthesisEvent;
318
+ SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
319
+ };
320
+
321
+ type FetchAuthorizationTokenInit = {
322
+ region: string;
323
+ subscriptionKey: string;
324
+ };
325
+ declare function fetchAuthorizationToken({ region, subscriptionKey }: FetchAuthorizationTokenInit): Promise<string>;
326
+
327
+ declare function createSpeechServicesPonyfill(options?: any): any;
328
+
329
+ export { createSpeechRecognitionPonyfill, createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill, _default as createSpeechSynthesisPonyfill, fetchAuthorizationToken };