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.
@@ -74,6 +74,91 @@ declare class _default$4 {
74
74
  stop(): void;
75
75
  }
76
76
 
77
+ declare class EventListenerMap<T extends string, EventMap extends Record<T, Event>> {
78
+ #private;
79
+ constructor(eventTarget: EventTarget);
80
+ getProperty(name: T): ((event: EventMap[typeof name]) => void) | undefined;
81
+ setProperty(name: T, value: ((event: EventMap[typeof name]) => void) | undefined): void;
82
+ }
83
+
84
+ type SpeechRecognitionErrorType = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed';
85
+ type SpeechRecognitionErrorEventInit = {
86
+ error: SpeechRecognitionErrorType;
87
+ message?: string | undefined;
88
+ };
89
+ declare class SpeechRecognitionErrorEvent extends Event {
90
+ #private;
91
+ constructor(type: 'error', { error, message }: SpeechRecognitionErrorEventInit);
92
+ get error(): SpeechRecognitionErrorType;
93
+ get message(): string | undefined;
94
+ }
95
+
96
+ interface FakeArrayInterface<T> {
97
+ [index: number]: T | undefined;
98
+ get length(): number;
99
+ }
100
+ declare class FakeArray<T> implements FakeArrayInterface<T> {
101
+ #private;
102
+ constructor(array: readonly T[]);
103
+ [index: number]: T | undefined;
104
+ [Symbol.iterator](): IterableIterator<T>;
105
+ get length(): number;
106
+ }
107
+
108
+ type SpeechRecognitionResultInit = {
109
+ isFinal: boolean;
110
+ results: readonly SpeechRecognitionAlternative[];
111
+ };
112
+ declare class SpeechRecognitionResult extends FakeArray<SpeechRecognitionAlternative> {
113
+ #private;
114
+ constructor(init: SpeechRecognitionResultInit);
115
+ get isFinal(): boolean;
116
+ }
117
+
118
+ declare class SpeechRecognitionResultList extends FakeArray<SpeechRecognitionResult> {
119
+ constructor(result: readonly SpeechRecognitionResult[]);
120
+ }
121
+
122
+ type SpeechRecognitionEventInit = {
123
+ data?: undefined | unknown;
124
+ resultIndex?: number | undefined;
125
+ results?: SpeechRecognitionResultList | undefined;
126
+ };
127
+ declare class SpeechRecognitionEvent<T extends 'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start'> extends Event {
128
+ #private;
129
+ constructor(type: 'cognitiveservices', init: SpeechRecognitionEventInit & {
130
+ data: {
131
+ type: string;
132
+ };
133
+ });
134
+ constructor(type: 'audioend');
135
+ constructor(type: 'audiostart');
136
+ constructor(type: 'end');
137
+ constructor(type: 'result', init: SpeechRecognitionEventInit);
138
+ constructor(type: 'soundend');
139
+ constructor(type: 'soundstart');
140
+ constructor(type: 'speechend');
141
+ constructor(type: 'speechstart');
142
+ constructor(type: 'start');
143
+ get data(): unknown;
144
+ get resultIndex(): number | undefined;
145
+ get results(): SpeechRecognitionResultList;
146
+ }
147
+
148
+ type SpeechRecognitionEventListenerMap = EventListenerMap<'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'error' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start', {
149
+ audioend: SpeechRecognitionEvent<'audioend'>;
150
+ audiostart: SpeechRecognitionEvent<'audiostart'>;
151
+ cognitiveservices: SpeechRecognitionEvent<'cognitiveservices'>;
152
+ end: SpeechRecognitionEvent<'end'>;
153
+ error: SpeechRecognitionErrorEvent;
154
+ result: SpeechRecognitionEvent<'result'>;
155
+ soundend: SpeechRecognitionEvent<'soundend'>;
156
+ soundstart: SpeechRecognitionEvent<'soundstart'>;
157
+ speechend: SpeechRecognitionEvent<'speechend'>;
158
+ speechstart: SpeechRecognitionEvent<'speechstart'>;
159
+ start: SpeechRecognitionEvent<'start'>;
160
+ }>;
161
+
77
162
  declare class _default$3 {
78
163
  _phrases: any[];
79
164
  addFromString(): void;
@@ -96,48 +181,60 @@ declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognize
96
181
  _lang: string;
97
182
  _grammars: _default$3;
98
183
  _maxAlternatives: number;
184
+ /** @type { import('./SpeechRecognitionEventListenerMap').SpeechRecognitionEventListenerMap } */
185
+ "__#7@#eventListenerMap": SpeechRecognitionEventListenerMap;
99
186
  emitCognitiveServices(type: any, event: any): void;
100
187
  continuous: boolean;
101
188
  grammars: _default$3;
102
189
  interimResults: boolean;
103
190
  maxAlternatives: number;
104
191
  lang: string;
105
- onaudioend: any;
106
- onaudiostart: any;
107
- oncognitiveservices: any;
108
- onend: any;
109
- onerror: any;
110
- onresult: any;
111
- onsoundend: any;
112
- onsoundstart: any;
113
- onspeechend: any;
114
- onspeechstart: any;
115
- onstart: any;
192
+ /** @type { ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined } */
193
+ get onaudioend(): ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined;
194
+ set onaudioend(value: ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined);
195
+ /** @type { ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined } */
196
+ get onaudiostart(): ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined;
197
+ set onaudiostart(value: ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined);
198
+ /** @type { ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined } */
199
+ get oncognitiveservices(): ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined;
200
+ set oncognitiveservices(value: ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined);
201
+ /** @type { ((event: SpeechRecognitionEvent<'end'>) => void) | undefined } */
202
+ get onend(): ((event: SpeechRecognitionEvent<'end'>) => void) | undefined;
203
+ set onend(value: ((event: SpeechRecognitionEvent<'end'>) => void) | undefined);
204
+ /** @type { ((event: SpeechRecognitionEvent<'error'>) => void) | undefined } */
205
+ get onerror(): ((event: SpeechRecognitionEvent<'error'>) => void) | undefined;
206
+ set onerror(value: ((event: SpeechRecognitionEvent<'error'>) => void) | undefined);
207
+ /** @type { ((event: SpeechRecognitionEvent<'result'>) => void) | undefined } */
208
+ get onresult(): ((event: SpeechRecognitionEvent<'result'>) => void) | undefined;
209
+ set onresult(value: ((event: SpeechRecognitionEvent<'result'>) => void) | undefined);
210
+ /** @type { ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined } */
211
+ get onsoundend(): ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined;
212
+ set onsoundend(value: ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined);
213
+ /** @type { ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined } */
214
+ get onsoundstart(): ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined;
215
+ set onsoundstart(value: ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined);
216
+ /** @type { ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined } */
217
+ get onspeechend(): ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined;
218
+ set onspeechend(value: ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined);
219
+ /** @type { ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined } */
220
+ get onspeechstart(): ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined;
221
+ set onspeechstart(value: ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined);
222
+ /** @type { ((event: SpeechRecognitionEvent<'start'>) => void) | undefined } */
223
+ get onstart(): ((event: SpeechRecognitionEvent<'start'>) => void) | undefined;
224
+ set onstart(value: ((event: SpeechRecognitionEvent<'start'>) => void) | undefined);
116
225
  start(): void;
117
226
  _startOnce(): Promise<void>;
118
227
  abort: (() => void) | undefined;
119
228
  stop: (() => void) | undefined;
229
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
230
+ dispatchEvent(event: Event): boolean;
231
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void;
120
232
  };
121
233
  };
122
234
  SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
123
235
  };
124
236
  declare function _default$2(options: any): {};
125
237
 
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
-
141
238
  declare function _default$1(options: any): {
142
239
  speechSynthesis?: never;
143
240
  SpeechSynthesisEvent?: never;
@@ -74,6 +74,91 @@ declare class _default$4 {
74
74
  stop(): void;
75
75
  }
76
76
 
77
+ declare class EventListenerMap<T extends string, EventMap extends Record<T, Event>> {
78
+ #private;
79
+ constructor(eventTarget: EventTarget);
80
+ getProperty(name: T): ((event: EventMap[typeof name]) => void) | undefined;
81
+ setProperty(name: T, value: ((event: EventMap[typeof name]) => void) | undefined): void;
82
+ }
83
+
84
+ type SpeechRecognitionErrorType = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed';
85
+ type SpeechRecognitionErrorEventInit = {
86
+ error: SpeechRecognitionErrorType;
87
+ message?: string | undefined;
88
+ };
89
+ declare class SpeechRecognitionErrorEvent extends Event {
90
+ #private;
91
+ constructor(type: 'error', { error, message }: SpeechRecognitionErrorEventInit);
92
+ get error(): SpeechRecognitionErrorType;
93
+ get message(): string | undefined;
94
+ }
95
+
96
+ interface FakeArrayInterface<T> {
97
+ [index: number]: T | undefined;
98
+ get length(): number;
99
+ }
100
+ declare class FakeArray<T> implements FakeArrayInterface<T> {
101
+ #private;
102
+ constructor(array: readonly T[]);
103
+ [index: number]: T | undefined;
104
+ [Symbol.iterator](): IterableIterator<T>;
105
+ get length(): number;
106
+ }
107
+
108
+ type SpeechRecognitionResultInit = {
109
+ isFinal: boolean;
110
+ results: readonly SpeechRecognitionAlternative[];
111
+ };
112
+ declare class SpeechRecognitionResult extends FakeArray<SpeechRecognitionAlternative> {
113
+ #private;
114
+ constructor(init: SpeechRecognitionResultInit);
115
+ get isFinal(): boolean;
116
+ }
117
+
118
+ declare class SpeechRecognitionResultList extends FakeArray<SpeechRecognitionResult> {
119
+ constructor(result: readonly SpeechRecognitionResult[]);
120
+ }
121
+
122
+ type SpeechRecognitionEventInit = {
123
+ data?: undefined | unknown;
124
+ resultIndex?: number | undefined;
125
+ results?: SpeechRecognitionResultList | undefined;
126
+ };
127
+ declare class SpeechRecognitionEvent<T extends 'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start'> extends Event {
128
+ #private;
129
+ constructor(type: 'cognitiveservices', init: SpeechRecognitionEventInit & {
130
+ data: {
131
+ type: string;
132
+ };
133
+ });
134
+ constructor(type: 'audioend');
135
+ constructor(type: 'audiostart');
136
+ constructor(type: 'end');
137
+ constructor(type: 'result', init: SpeechRecognitionEventInit);
138
+ constructor(type: 'soundend');
139
+ constructor(type: 'soundstart');
140
+ constructor(type: 'speechend');
141
+ constructor(type: 'speechstart');
142
+ constructor(type: 'start');
143
+ get data(): unknown;
144
+ get resultIndex(): number | undefined;
145
+ get results(): SpeechRecognitionResultList;
146
+ }
147
+
148
+ type SpeechRecognitionEventListenerMap = EventListenerMap<'audioend' | 'audiostart' | 'cognitiveservices' | 'end' | 'error' | 'result' | 'soundend' | 'soundstart' | 'speechend' | 'speechstart' | 'start', {
149
+ audioend: SpeechRecognitionEvent<'audioend'>;
150
+ audiostart: SpeechRecognitionEvent<'audiostart'>;
151
+ cognitiveservices: SpeechRecognitionEvent<'cognitiveservices'>;
152
+ end: SpeechRecognitionEvent<'end'>;
153
+ error: SpeechRecognitionErrorEvent;
154
+ result: SpeechRecognitionEvent<'result'>;
155
+ soundend: SpeechRecognitionEvent<'soundend'>;
156
+ soundstart: SpeechRecognitionEvent<'soundstart'>;
157
+ speechend: SpeechRecognitionEvent<'speechend'>;
158
+ speechstart: SpeechRecognitionEvent<'speechstart'>;
159
+ start: SpeechRecognitionEvent<'start'>;
160
+ }>;
161
+
77
162
  declare class _default$3 {
78
163
  _phrases: any[];
79
164
  addFromString(): void;
@@ -96,48 +181,60 @@ declare function createSpeechRecognitionPonyfillFromRecognizer({ createRecognize
96
181
  _lang: string;
97
182
  _grammars: _default$3;
98
183
  _maxAlternatives: number;
184
+ /** @type { import('./SpeechRecognitionEventListenerMap').SpeechRecognitionEventListenerMap } */
185
+ "__#7@#eventListenerMap": SpeechRecognitionEventListenerMap;
99
186
  emitCognitiveServices(type: any, event: any): void;
100
187
  continuous: boolean;
101
188
  grammars: _default$3;
102
189
  interimResults: boolean;
103
190
  maxAlternatives: number;
104
191
  lang: string;
105
- onaudioend: any;
106
- onaudiostart: any;
107
- oncognitiveservices: any;
108
- onend: any;
109
- onerror: any;
110
- onresult: any;
111
- onsoundend: any;
112
- onsoundstart: any;
113
- onspeechend: any;
114
- onspeechstart: any;
115
- onstart: any;
192
+ /** @type { ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined } */
193
+ get onaudioend(): ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined;
194
+ set onaudioend(value: ((event: SpeechRecognitionEvent<'audioend'>) => void) | undefined);
195
+ /** @type { ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined } */
196
+ get onaudiostart(): ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined;
197
+ set onaudiostart(value: ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined);
198
+ /** @type { ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined } */
199
+ get oncognitiveservices(): ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined;
200
+ set oncognitiveservices(value: ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined);
201
+ /** @type { ((event: SpeechRecognitionEvent<'end'>) => void) | undefined } */
202
+ get onend(): ((event: SpeechRecognitionEvent<'end'>) => void) | undefined;
203
+ set onend(value: ((event: SpeechRecognitionEvent<'end'>) => void) | undefined);
204
+ /** @type { ((event: SpeechRecognitionEvent<'error'>) => void) | undefined } */
205
+ get onerror(): ((event: SpeechRecognitionEvent<'error'>) => void) | undefined;
206
+ set onerror(value: ((event: SpeechRecognitionEvent<'error'>) => void) | undefined);
207
+ /** @type { ((event: SpeechRecognitionEvent<'result'>) => void) | undefined } */
208
+ get onresult(): ((event: SpeechRecognitionEvent<'result'>) => void) | undefined;
209
+ set onresult(value: ((event: SpeechRecognitionEvent<'result'>) => void) | undefined);
210
+ /** @type { ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined } */
211
+ get onsoundend(): ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined;
212
+ set onsoundend(value: ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined);
213
+ /** @type { ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined } */
214
+ get onsoundstart(): ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined;
215
+ set onsoundstart(value: ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined);
216
+ /** @type { ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined } */
217
+ get onspeechend(): ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined;
218
+ set onspeechend(value: ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined);
219
+ /** @type { ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined } */
220
+ get onspeechstart(): ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined;
221
+ set onspeechstart(value: ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined);
222
+ /** @type { ((event: SpeechRecognitionEvent<'start'>) => void) | undefined } */
223
+ get onstart(): ((event: SpeechRecognitionEvent<'start'>) => void) | undefined;
224
+ set onstart(value: ((event: SpeechRecognitionEvent<'start'>) => void) | undefined);
116
225
  start(): void;
117
226
  _startOnce(): Promise<void>;
118
227
  abort: (() => void) | undefined;
119
228
  stop: (() => void) | undefined;
229
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
230
+ dispatchEvent(event: Event): boolean;
231
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void;
120
232
  };
121
233
  };
122
234
  SpeechRecognitionEvent: typeof SpeechRecognitionEvent;
123
235
  };
124
236
  declare function _default$2(options: any): {};
125
237
 
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
-
141
238
  declare function _default$1(options: any): {
142
239
  speechSynthesis?: never;
143
240
  SpeechSynthesisEvent?: never;