web-speech-cognitive-services 8.0.0-main.aa5b13b → 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 +189 -58
- package/dist/web-speech-cognitive-services.d.ts +189 -58
- package/dist/web-speech-cognitive-services.development.js +1457 -1382
- package/dist/web-speech-cognitive-services.development.js.map +1 -1
- package/dist/web-speech-cognitive-services.js +453 -316
- package/dist/web-speech-cognitive-services.js.map +1 -1
- package/dist/web-speech-cognitive-services.mjs +452 -315
- 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 +4 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as memoize_one from 'memoize-one';
|
|
2
|
+
import { AudioConfig, SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
|
|
2
3
|
|
|
3
4
|
declare class SpeechSynthesisUtterance {
|
|
4
5
|
constructor(text: any);
|
|
@@ -47,7 +48,7 @@ declare class SpeechSynthesisEvent {
|
|
|
47
48
|
constructor(type: any);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
declare class _default$
|
|
51
|
+
declare class _default$2 {
|
|
51
52
|
constructor(audioContext: any);
|
|
52
53
|
audioContext: any;
|
|
53
54
|
pause(): void;
|
|
@@ -57,12 +58,12 @@ declare class _default$5 {
|
|
|
57
58
|
stop(): void;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
declare class _default$
|
|
61
|
+
declare class _default$1 {
|
|
61
62
|
constructor({ audioContext, ponyfill }: {
|
|
62
63
|
audioContext: any;
|
|
63
64
|
ponyfill: any;
|
|
64
65
|
});
|
|
65
|
-
consumer: _default$
|
|
66
|
+
consumer: _default$2 | null;
|
|
66
67
|
paused: boolean;
|
|
67
68
|
queue: any[];
|
|
68
69
|
getAudioContext: memoize_one.MemoizedFn<() => any>;
|
|
@@ -74,71 +75,200 @@ declare class _default$4 {
|
|
|
74
75
|
stop(): void;
|
|
75
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): {};
|
|
114
|
+
|
|
115
|
+
declare class SpeechGrammarList {
|
|
116
|
+
#private;
|
|
117
|
+
constructor();
|
|
79
118
|
addFromString(): void;
|
|
80
|
-
|
|
81
|
-
|
|
119
|
+
get phrases(): readonly string[];
|
|
120
|
+
set phrases(value: readonly string[]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
type SpeechRecognitionErrorType = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed' | 'unknown';
|
|
124
|
+
type SpeechRecognitionErrorEventInit = {
|
|
125
|
+
error: SpeechRecognitionErrorType;
|
|
126
|
+
message?: string | undefined;
|
|
127
|
+
};
|
|
128
|
+
declare class SpeechRecognitionErrorEvent extends Event {
|
|
129
|
+
#private;
|
|
130
|
+
constructor(type: 'error', { error, message }: SpeechRecognitionErrorEventInit);
|
|
131
|
+
get error(): SpeechRecognitionErrorType;
|
|
132
|
+
get message(): string | undefined;
|
|
133
|
+
get type(): 'error';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface FakeArrayInterface<T> {
|
|
137
|
+
[index: number]: T | undefined;
|
|
138
|
+
get length(): number;
|
|
139
|
+
}
|
|
140
|
+
declare class FakeArray<T> implements FakeArrayInterface<T> {
|
|
141
|
+
#private;
|
|
142
|
+
constructor(array: readonly T[]);
|
|
143
|
+
[index: number]: T | undefined;
|
|
144
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
145
|
+
get length(): number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type SpeechRecognitionResultInit = {
|
|
149
|
+
isFinal: boolean;
|
|
150
|
+
results: readonly SpeechRecognitionAlternative[];
|
|
151
|
+
};
|
|
152
|
+
declare class SpeechRecognitionResult extends FakeArray<SpeechRecognitionAlternative> {
|
|
153
|
+
#private;
|
|
154
|
+
constructor(init: SpeechRecognitionResultInit);
|
|
155
|
+
get isFinal(): boolean;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare class SpeechRecognitionResultList extends FakeArray<SpeechRecognitionResult> {
|
|
159
|
+
constructor(result: readonly SpeechRecognitionResult[]);
|
|
82
160
|
}
|
|
83
161
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
162
|
+
type SpeechRecognitionEventInit = {
|
|
163
|
+
data?: undefined | unknown;
|
|
164
|
+
resultIndex?: number | undefined;
|
|
165
|
+
results?: SpeechRecognitionResultList | undefined;
|
|
166
|
+
};
|
|
167
|
+
declare class SpeechRecognitionEvent<T extends 'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start'> extends Event {
|
|
168
|
+
#private;
|
|
169
|
+
constructor(type: 'cognitiveservices', init: SpeechRecognitionEventInit & {
|
|
170
|
+
data: {
|
|
171
|
+
type: string;
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
constructor(type: 'audioend');
|
|
175
|
+
constructor(type: 'audiostart');
|
|
176
|
+
constructor(type: 'end');
|
|
177
|
+
constructor(type: 'result', init: SpeechRecognitionEventInit);
|
|
178
|
+
constructor(type: 'soundend');
|
|
179
|
+
constructor(type: 'soundstart');
|
|
180
|
+
constructor(type: 'speechend');
|
|
181
|
+
constructor(type: 'speechstart');
|
|
182
|
+
constructor(type: 'start');
|
|
183
|
+
get data(): unknown;
|
|
184
|
+
get resultIndex(): number | undefined;
|
|
185
|
+
get results(): SpeechRecognitionResultList;
|
|
186
|
+
get type(): T;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class EventListenerMap<T extends string, EventMap extends {
|
|
190
|
+
[Name in T]: unknown;
|
|
191
|
+
}> {
|
|
192
|
+
#private;
|
|
193
|
+
constructor(eventTarget: EventTarget);
|
|
194
|
+
getProperty<U extends T>(name: U): ((event: EventMap[U]) => void) | undefined;
|
|
195
|
+
setProperty<U extends T>(name: U, value: ((event: EventMap[U]) => void) | undefined): void;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
type SpeechRecognitionEventListenerMap = EventListenerMap<'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'error' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start', {
|
|
199
|
+
audioend: SpeechRecognitionEvent<'audioend'>;
|
|
200
|
+
audiostart: SpeechRecognitionEvent<'audiostart'>;
|
|
201
|
+
cognitiveservices: SpeechRecognitionEvent<'cognitiveservices'>;
|
|
202
|
+
end: SpeechRecognitionEvent<'end'>;
|
|
203
|
+
error: SpeechRecognitionErrorEvent;
|
|
204
|
+
result: SpeechRecognitionEvent<'result'>;
|
|
205
|
+
soundend: SpeechRecognitionEvent<'soundend'>;
|
|
206
|
+
soundstart: SpeechRecognitionEvent<'soundstart'>;
|
|
207
|
+
speechend: SpeechRecognitionEvent<'speechend'>;
|
|
208
|
+
speechstart: SpeechRecognitionEvent<'speechstart'>;
|
|
209
|
+
start: SpeechRecognitionEvent<'start'>;
|
|
210
|
+
}>;
|
|
211
|
+
|
|
212
|
+
type CreateSpeechRecognitionPonyfillFromRecognizerInit = {
|
|
213
|
+
createRecognizer: (lang: string) => Promise<SpeechRecognizer>;
|
|
214
|
+
enableTelemetry: boolean;
|
|
215
|
+
looseEvents: boolean;
|
|
216
|
+
referenceGrammars?: readonly string[] | undefined;
|
|
217
|
+
textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
|
|
218
|
+
};
|
|
219
|
+
declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognizer, enableTelemetry, looseEvents, referenceGrammars, textNormalization }: CreateSpeechRecognitionPonyfillFromRecognizerInit): {
|
|
220
|
+
SpeechGrammarList: typeof SpeechGrammarList;
|
|
92
221
|
SpeechRecognition: {
|
|
93
222
|
new (): {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
223
|
+
"__#8@#continuous": boolean;
|
|
224
|
+
"__#8@#eventListenerMap": SpeechRecognitionEventListenerMap;
|
|
225
|
+
"__#8@#grammars": SpeechGrammarList;
|
|
226
|
+
"__#8@#interimResults": boolean;
|
|
227
|
+
"__#8@#lang": string;
|
|
228
|
+
"__#8@#maxAlternatives": number;
|
|
229
|
+
emitCognitiveServices<T extends {
|
|
230
|
+
type: string;
|
|
231
|
+
}>(type: string, event: T): void;
|
|
100
232
|
continuous: boolean;
|
|
101
|
-
grammars:
|
|
233
|
+
grammars: SpeechGrammarList;
|
|
102
234
|
interimResults: boolean;
|
|
103
235
|
maxAlternatives: number;
|
|
104
236
|
lang: string;
|
|
105
|
-
onaudioend:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
237
|
+
get onaudioend(): ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined;
|
|
238
|
+
set onaudioend(value: ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined);
|
|
239
|
+
/** @type { ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined } */
|
|
240
|
+
onaudiostart: ((event: SpeechRecognitionEvent<"audiostart">) => void) | undefined;
|
|
241
|
+
/** @type { ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined } */
|
|
242
|
+
oncognitiveservices: ((event: SpeechRecognitionEvent<"cognitiveservices">) => void) | undefined;
|
|
243
|
+
/** @type { ((event: SpeechRecognitionEvent<'end'>) => void) | undefined } */
|
|
244
|
+
onend: ((event: SpeechRecognitionEvent<"end">) => void) | undefined;
|
|
245
|
+
/** @type { ((event: SpeechRecognitionErrorEvent) => void) | undefined } */
|
|
246
|
+
onerror: ((event: SpeechRecognitionErrorEvent) => void) | undefined;
|
|
247
|
+
/** @type { ((event: SpeechRecognitionEvent<'result'>) => void) | undefined } */
|
|
248
|
+
onresult: ((event: SpeechRecognitionEvent<"result">) => void) | undefined;
|
|
249
|
+
/** @type { ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined } */
|
|
250
|
+
onsoundend: ((event: SpeechRecognitionEvent<"soundend">) => void) | undefined;
|
|
251
|
+
/** @type { ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined } */
|
|
252
|
+
onsoundstart: ((event: SpeechRecognitionEvent<"soundstart">) => void) | undefined;
|
|
253
|
+
/** @type { ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined } */
|
|
254
|
+
onspeechend: ((event: SpeechRecognitionEvent<"speechend">) => void) | undefined;
|
|
255
|
+
/** @type { ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined } */
|
|
256
|
+
onspeechstart: ((event: SpeechRecognitionEvent<"speechstart">) => void) | undefined;
|
|
257
|
+
/** @type { ((event: SpeechRecognitionEvent<'start'>) => void) | undefined } */
|
|
258
|
+
onstart: ((event: SpeechRecognitionEvent<"start">) => void) | undefined;
|
|
118
259
|
abort: (() => void) | undefined;
|
|
119
260
|
stop: (() => void) | undefined;
|
|
261
|
+
start(): void;
|
|
262
|
+
_startOnce(): Promise<void>;
|
|
263
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
264
|
+
dispatchEvent(event: Event): boolean;
|
|
265
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void;
|
|
120
266
|
};
|
|
121
267
|
};
|
|
122
268
|
SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
|
|
123
269
|
};
|
|
124
|
-
declare function _default$2(options: any): {};
|
|
125
|
-
|
|
126
|
-
declare class SpeechRecognitionEvent {
|
|
127
|
-
constructor(type: any, { data, emma, interpretation, resultIndex, results }?: {
|
|
128
|
-
data: any;
|
|
129
|
-
emma: any;
|
|
130
|
-
interpretation: any;
|
|
131
|
-
resultIndex: any;
|
|
132
|
-
results: any;
|
|
133
|
-
});
|
|
134
|
-
data: any;
|
|
135
|
-
emma: any;
|
|
136
|
-
interpretation: any;
|
|
137
|
-
resultIndex: any;
|
|
138
|
-
results: any;
|
|
139
|
-
}
|
|
140
270
|
|
|
141
|
-
declare function _default
|
|
271
|
+
declare function _default(options: any): {
|
|
142
272
|
speechSynthesis?: never;
|
|
143
273
|
SpeechSynthesisEvent?: never;
|
|
144
274
|
SpeechSynthesisUtterance?: never;
|
|
@@ -158,10 +288,11 @@ declare function _default$1(options: any): {
|
|
|
158
288
|
SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
|
|
159
289
|
};
|
|
160
290
|
|
|
161
|
-
|
|
162
|
-
region:
|
|
163
|
-
subscriptionKey:
|
|
164
|
-
}
|
|
291
|
+
type FetchAuthorizationTokenInit = {
|
|
292
|
+
region: string;
|
|
293
|
+
subscriptionKey: string;
|
|
294
|
+
};
|
|
295
|
+
declare function fetchAuthorizationToken({ region, subscriptionKey }: FetchAuthorizationTokenInit): Promise<string>;
|
|
165
296
|
|
|
166
297
|
declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
167
298
|
speechSynthesis?: never;
|
|
@@ -169,7 +300,7 @@ declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
|
169
300
|
SpeechSynthesisUtterance?: never;
|
|
170
301
|
} | {
|
|
171
302
|
speechSynthesis: {
|
|
172
|
-
queue: _default$
|
|
303
|
+
queue: _default$1;
|
|
173
304
|
cancel(): void;
|
|
174
305
|
getVoices(): any[];
|
|
175
306
|
onvoiceschanged: any;
|
|
@@ -183,4 +314,4 @@ declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
|
183
314
|
SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
|
|
184
315
|
};
|
|
185
316
|
|
|
186
|
-
export {
|
|
317
|
+
export { createSpeechRecognitionPonyfill, createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill, _default as createSpeechSynthesisPonyfill, fetchAuthorizationToken };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as memoize_one from 'memoize-one';
|
|
2
|
+
import { AudioConfig, SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
|
|
2
3
|
|
|
3
4
|
declare class SpeechSynthesisUtterance {
|
|
4
5
|
constructor(text: any);
|
|
@@ -47,7 +48,7 @@ declare class SpeechSynthesisEvent {
|
|
|
47
48
|
constructor(type: any);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
declare class _default$
|
|
51
|
+
declare class _default$2 {
|
|
51
52
|
constructor(audioContext: any);
|
|
52
53
|
audioContext: any;
|
|
53
54
|
pause(): void;
|
|
@@ -57,12 +58,12 @@ declare class _default$5 {
|
|
|
57
58
|
stop(): void;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
declare class _default$
|
|
61
|
+
declare class _default$1 {
|
|
61
62
|
constructor({ audioContext, ponyfill }: {
|
|
62
63
|
audioContext: any;
|
|
63
64
|
ponyfill: any;
|
|
64
65
|
});
|
|
65
|
-
consumer: _default$
|
|
66
|
+
consumer: _default$2 | null;
|
|
66
67
|
paused: boolean;
|
|
67
68
|
queue: any[];
|
|
68
69
|
getAudioContext: memoize_one.MemoizedFn<() => any>;
|
|
@@ -74,71 +75,200 @@ declare class _default$4 {
|
|
|
74
75
|
stop(): void;
|
|
75
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): {};
|
|
114
|
+
|
|
115
|
+
declare class SpeechGrammarList {
|
|
116
|
+
#private;
|
|
117
|
+
constructor();
|
|
79
118
|
addFromString(): void;
|
|
80
|
-
|
|
81
|
-
|
|
119
|
+
get phrases(): readonly string[];
|
|
120
|
+
set phrases(value: readonly string[]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
type SpeechRecognitionErrorType = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed' | 'unknown';
|
|
124
|
+
type SpeechRecognitionErrorEventInit = {
|
|
125
|
+
error: SpeechRecognitionErrorType;
|
|
126
|
+
message?: string | undefined;
|
|
127
|
+
};
|
|
128
|
+
declare class SpeechRecognitionErrorEvent extends Event {
|
|
129
|
+
#private;
|
|
130
|
+
constructor(type: 'error', { error, message }: SpeechRecognitionErrorEventInit);
|
|
131
|
+
get error(): SpeechRecognitionErrorType;
|
|
132
|
+
get message(): string | undefined;
|
|
133
|
+
get type(): 'error';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface FakeArrayInterface<T> {
|
|
137
|
+
[index: number]: T | undefined;
|
|
138
|
+
get length(): number;
|
|
139
|
+
}
|
|
140
|
+
declare class FakeArray<T> implements FakeArrayInterface<T> {
|
|
141
|
+
#private;
|
|
142
|
+
constructor(array: readonly T[]);
|
|
143
|
+
[index: number]: T | undefined;
|
|
144
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
145
|
+
get length(): number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type SpeechRecognitionResultInit = {
|
|
149
|
+
isFinal: boolean;
|
|
150
|
+
results: readonly SpeechRecognitionAlternative[];
|
|
151
|
+
};
|
|
152
|
+
declare class SpeechRecognitionResult extends FakeArray<SpeechRecognitionAlternative> {
|
|
153
|
+
#private;
|
|
154
|
+
constructor(init: SpeechRecognitionResultInit);
|
|
155
|
+
get isFinal(): boolean;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare class SpeechRecognitionResultList extends FakeArray<SpeechRecognitionResult> {
|
|
159
|
+
constructor(result: readonly SpeechRecognitionResult[]);
|
|
82
160
|
}
|
|
83
161
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
162
|
+
type SpeechRecognitionEventInit = {
|
|
163
|
+
data?: undefined | unknown;
|
|
164
|
+
resultIndex?: number | undefined;
|
|
165
|
+
results?: SpeechRecognitionResultList | undefined;
|
|
166
|
+
};
|
|
167
|
+
declare class SpeechRecognitionEvent<T extends 'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start'> extends Event {
|
|
168
|
+
#private;
|
|
169
|
+
constructor(type: 'cognitiveservices', init: SpeechRecognitionEventInit & {
|
|
170
|
+
data: {
|
|
171
|
+
type: string;
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
constructor(type: 'audioend');
|
|
175
|
+
constructor(type: 'audiostart');
|
|
176
|
+
constructor(type: 'end');
|
|
177
|
+
constructor(type: 'result', init: SpeechRecognitionEventInit);
|
|
178
|
+
constructor(type: 'soundend');
|
|
179
|
+
constructor(type: 'soundstart');
|
|
180
|
+
constructor(type: 'speechend');
|
|
181
|
+
constructor(type: 'speechstart');
|
|
182
|
+
constructor(type: 'start');
|
|
183
|
+
get data(): unknown;
|
|
184
|
+
get resultIndex(): number | undefined;
|
|
185
|
+
get results(): SpeechRecognitionResultList;
|
|
186
|
+
get type(): T;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class EventListenerMap<T extends string, EventMap extends {
|
|
190
|
+
[Name in T]: unknown;
|
|
191
|
+
}> {
|
|
192
|
+
#private;
|
|
193
|
+
constructor(eventTarget: EventTarget);
|
|
194
|
+
getProperty<U extends T>(name: U): ((event: EventMap[U]) => void) | undefined;
|
|
195
|
+
setProperty<U extends T>(name: U, value: ((event: EventMap[U]) => void) | undefined): void;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
type SpeechRecognitionEventListenerMap = EventListenerMap<'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'error' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start', {
|
|
199
|
+
audioend: SpeechRecognitionEvent<'audioend'>;
|
|
200
|
+
audiostart: SpeechRecognitionEvent<'audiostart'>;
|
|
201
|
+
cognitiveservices: SpeechRecognitionEvent<'cognitiveservices'>;
|
|
202
|
+
end: SpeechRecognitionEvent<'end'>;
|
|
203
|
+
error: SpeechRecognitionErrorEvent;
|
|
204
|
+
result: SpeechRecognitionEvent<'result'>;
|
|
205
|
+
soundend: SpeechRecognitionEvent<'soundend'>;
|
|
206
|
+
soundstart: SpeechRecognitionEvent<'soundstart'>;
|
|
207
|
+
speechend: SpeechRecognitionEvent<'speechend'>;
|
|
208
|
+
speechstart: SpeechRecognitionEvent<'speechstart'>;
|
|
209
|
+
start: SpeechRecognitionEvent<'start'>;
|
|
210
|
+
}>;
|
|
211
|
+
|
|
212
|
+
type CreateSpeechRecognitionPonyfillFromRecognizerInit = {
|
|
213
|
+
createRecognizer: (lang: string) => Promise<SpeechRecognizer>;
|
|
214
|
+
enableTelemetry: boolean;
|
|
215
|
+
looseEvents: boolean;
|
|
216
|
+
referenceGrammars?: readonly string[] | undefined;
|
|
217
|
+
textNormalization: 'display' | 'itn' | 'lexical' | 'maskeditn';
|
|
218
|
+
};
|
|
219
|
+
declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognizer, enableTelemetry, looseEvents, referenceGrammars, textNormalization }: CreateSpeechRecognitionPonyfillFromRecognizerInit): {
|
|
220
|
+
SpeechGrammarList: typeof SpeechGrammarList;
|
|
92
221
|
SpeechRecognition: {
|
|
93
222
|
new (): {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
223
|
+
"__#8@#continuous": boolean;
|
|
224
|
+
"__#8@#eventListenerMap": SpeechRecognitionEventListenerMap;
|
|
225
|
+
"__#8@#grammars": SpeechGrammarList;
|
|
226
|
+
"__#8@#interimResults": boolean;
|
|
227
|
+
"__#8@#lang": string;
|
|
228
|
+
"__#8@#maxAlternatives": number;
|
|
229
|
+
emitCognitiveServices<T extends {
|
|
230
|
+
type: string;
|
|
231
|
+
}>(type: string, event: T): void;
|
|
100
232
|
continuous: boolean;
|
|
101
|
-
grammars:
|
|
233
|
+
grammars: SpeechGrammarList;
|
|
102
234
|
interimResults: boolean;
|
|
103
235
|
maxAlternatives: number;
|
|
104
236
|
lang: string;
|
|
105
|
-
onaudioend:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
237
|
+
get onaudioend(): ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined;
|
|
238
|
+
set onaudioend(value: ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined);
|
|
239
|
+
/** @type { ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined } */
|
|
240
|
+
onaudiostart: ((event: SpeechRecognitionEvent<"audiostart">) => void) | undefined;
|
|
241
|
+
/** @type { ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined } */
|
|
242
|
+
oncognitiveservices: ((event: SpeechRecognitionEvent<"cognitiveservices">) => void) | undefined;
|
|
243
|
+
/** @type { ((event: SpeechRecognitionEvent<'end'>) => void) | undefined } */
|
|
244
|
+
onend: ((event: SpeechRecognitionEvent<"end">) => void) | undefined;
|
|
245
|
+
/** @type { ((event: SpeechRecognitionErrorEvent) => void) | undefined } */
|
|
246
|
+
onerror: ((event: SpeechRecognitionErrorEvent) => void) | undefined;
|
|
247
|
+
/** @type { ((event: SpeechRecognitionEvent<'result'>) => void) | undefined } */
|
|
248
|
+
onresult: ((event: SpeechRecognitionEvent<"result">) => void) | undefined;
|
|
249
|
+
/** @type { ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined } */
|
|
250
|
+
onsoundend: ((event: SpeechRecognitionEvent<"soundend">) => void) | undefined;
|
|
251
|
+
/** @type { ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined } */
|
|
252
|
+
onsoundstart: ((event: SpeechRecognitionEvent<"soundstart">) => void) | undefined;
|
|
253
|
+
/** @type { ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined } */
|
|
254
|
+
onspeechend: ((event: SpeechRecognitionEvent<"speechend">) => void) | undefined;
|
|
255
|
+
/** @type { ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined } */
|
|
256
|
+
onspeechstart: ((event: SpeechRecognitionEvent<"speechstart">) => void) | undefined;
|
|
257
|
+
/** @type { ((event: SpeechRecognitionEvent<'start'>) => void) | undefined } */
|
|
258
|
+
onstart: ((event: SpeechRecognitionEvent<"start">) => void) | undefined;
|
|
118
259
|
abort: (() => void) | undefined;
|
|
119
260
|
stop: (() => void) | undefined;
|
|
261
|
+
start(): void;
|
|
262
|
+
_startOnce(): Promise<void>;
|
|
263
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
264
|
+
dispatchEvent(event: Event): boolean;
|
|
265
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void;
|
|
120
266
|
};
|
|
121
267
|
};
|
|
122
268
|
SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
|
|
123
269
|
};
|
|
124
|
-
declare function _default$2(options: any): {};
|
|
125
|
-
|
|
126
|
-
declare class SpeechRecognitionEvent {
|
|
127
|
-
constructor(type: any, { data, emma, interpretation, resultIndex, results }?: {
|
|
128
|
-
data: any;
|
|
129
|
-
emma: any;
|
|
130
|
-
interpretation: any;
|
|
131
|
-
resultIndex: any;
|
|
132
|
-
results: any;
|
|
133
|
-
});
|
|
134
|
-
data: any;
|
|
135
|
-
emma: any;
|
|
136
|
-
interpretation: any;
|
|
137
|
-
resultIndex: any;
|
|
138
|
-
results: any;
|
|
139
|
-
}
|
|
140
270
|
|
|
141
|
-
declare function _default
|
|
271
|
+
declare function _default(options: any): {
|
|
142
272
|
speechSynthesis?: never;
|
|
143
273
|
SpeechSynthesisEvent?: never;
|
|
144
274
|
SpeechSynthesisUtterance?: never;
|
|
@@ -158,10 +288,11 @@ declare function _default$1(options: any): {
|
|
|
158
288
|
SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
|
|
159
289
|
};
|
|
160
290
|
|
|
161
|
-
|
|
162
|
-
region:
|
|
163
|
-
subscriptionKey:
|
|
164
|
-
}
|
|
291
|
+
type FetchAuthorizationTokenInit = {
|
|
292
|
+
region: string;
|
|
293
|
+
subscriptionKey: string;
|
|
294
|
+
};
|
|
295
|
+
declare function fetchAuthorizationToken({ region, subscriptionKey }: FetchAuthorizationTokenInit): Promise<string>;
|
|
165
296
|
|
|
166
297
|
declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
167
298
|
speechSynthesis?: never;
|
|
@@ -169,7 +300,7 @@ declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
|
169
300
|
SpeechSynthesisUtterance?: never;
|
|
170
301
|
} | {
|
|
171
302
|
speechSynthesis: {
|
|
172
|
-
queue: _default$
|
|
303
|
+
queue: _default$1;
|
|
173
304
|
cancel(): void;
|
|
174
305
|
getVoices(): any[];
|
|
175
306
|
onvoiceschanged: any;
|
|
@@ -183,4 +314,4 @@ declare function createSpeechServicesPonyfill(options?: {}, ...args: any[]): {
|
|
|
183
314
|
SpeechSynthesisUtterance: typeof SpeechSynthesisUtterance;
|
|
184
315
|
};
|
|
185
316
|
|
|
186
|
-
export {
|
|
317
|
+
export { createSpeechRecognitionPonyfill, createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill, _default as createSpeechSynthesisPonyfill, fetchAuthorizationToken };
|