@capgo/capacitor-speech-synthesis 7.0.0
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/CapgoCapacitorSpeechSynthesis.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +507 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/ee/forgr/plugin/speechsynthesis/SpeechSynthesisPlugin.java +438 -0
- package/dist/docs.json +1089 -0
- package/dist/esm/definitions.d.ts +519 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +35 -0
- package/dist/esm/web.js +153 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +167 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +170 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/SpeechSynthesisPlugin/SpeechSynthesisPlugin.swift +338 -0
- package/ios/Tests/SpeechSynthesisPluginTests/SpeechSynthesisPluginTests.swift +10 -0
- package/package.json +86 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* Speech Synthesis Plugin for synthesizing speech from text.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
export interface SpeechSynthesisPlugin {
|
|
8
|
+
/**
|
|
9
|
+
* Speaks the given text with specified options.
|
|
10
|
+
* The utterance is added to the speech queue.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The speech options including text and voice settings
|
|
13
|
+
* @returns Promise resolving with the utterance ID
|
|
14
|
+
* @since 1.0.0
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const result = await SpeechSynthesis.speak({
|
|
18
|
+
* text: 'Hello, world!',
|
|
19
|
+
* language: 'en-US',
|
|
20
|
+
* rate: 1.0,
|
|
21
|
+
* pitch: 1.0,
|
|
22
|
+
* volume: 1.0,
|
|
23
|
+
* queueStrategy: 'Add'
|
|
24
|
+
* });
|
|
25
|
+
* console.log('Utterance ID:', result.utteranceId);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
speak(options: SpeakOptions): Promise<SpeakResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Synthesizes speech to an audio file (Android/iOS only).
|
|
31
|
+
* Returns the file path where the audio was saved.
|
|
32
|
+
*
|
|
33
|
+
* @param options - The speech options including text and voice settings
|
|
34
|
+
* @returns Promise resolving with the file path and utterance ID
|
|
35
|
+
* @since 1.0.0
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const result = await SpeechSynthesis.synthesizeToFile({
|
|
39
|
+
* text: 'Hello, world!',
|
|
40
|
+
* language: 'en-US'
|
|
41
|
+
* });
|
|
42
|
+
* console.log('Audio file saved at:', result.filePath);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
synthesizeToFile(options: SpeakOptions): Promise<SynthesizeToFileResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Cancels all queued utterances and stops current speech.
|
|
48
|
+
*
|
|
49
|
+
* @returns Promise that resolves when speech is cancelled
|
|
50
|
+
* @since 1.0.0
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* await SpeechSynthesis.cancel();
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
cancel(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Pauses speech immediately.
|
|
59
|
+
*
|
|
60
|
+
* @returns Promise that resolves when speech is paused
|
|
61
|
+
* @since 1.0.0
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* await SpeechSynthesis.pause();
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
pause(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Resumes paused speech.
|
|
70
|
+
*
|
|
71
|
+
* @returns Promise that resolves when speech is resumed
|
|
72
|
+
* @since 1.0.0
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* await SpeechSynthesis.resume();
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
resume(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Checks if speech synthesis is currently speaking.
|
|
81
|
+
*
|
|
82
|
+
* @returns Promise resolving with the speaking state
|
|
83
|
+
* @since 1.0.0
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const { isSpeaking } = await SpeechSynthesis.isSpeaking();
|
|
87
|
+
* console.log('Is speaking:', isSpeaking);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
isSpeaking(): Promise<{
|
|
91
|
+
isSpeaking: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Checks if speech synthesis is available on the device.
|
|
95
|
+
*
|
|
96
|
+
* @returns Promise resolving with the availability status
|
|
97
|
+
* @since 1.0.0
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const { isAvailable } = await SpeechSynthesis.isAvailable();
|
|
101
|
+
* if (isAvailable) {
|
|
102
|
+
* console.log('Speech synthesis is available');
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
isAvailable(): Promise<{
|
|
107
|
+
isAvailable: boolean;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Gets all available voices.
|
|
111
|
+
*
|
|
112
|
+
* @returns Promise resolving with the list of available voices
|
|
113
|
+
* @since 1.0.0
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const { voices } = await SpeechSynthesis.getVoices();
|
|
117
|
+
* voices.forEach(voice => {
|
|
118
|
+
* console.log(`${voice.name} (${voice.language})`);
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
getVoices(): Promise<{
|
|
123
|
+
voices: VoiceInfo[];
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Gets all available languages.
|
|
127
|
+
*
|
|
128
|
+
* @returns Promise resolving with the list of available language codes
|
|
129
|
+
* @since 1.0.0
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const { languages } = await SpeechSynthesis.getLanguages();
|
|
133
|
+
* console.log('Available languages:', languages);
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
getLanguages(): Promise<{
|
|
137
|
+
languages: string[];
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Checks if a specific language is available.
|
|
141
|
+
*
|
|
142
|
+
* @param options - The language to check
|
|
143
|
+
* @returns Promise resolving with the availability status
|
|
144
|
+
* @since 1.0.0
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const { isAvailable } = await SpeechSynthesis.isLanguageAvailable({
|
|
148
|
+
* language: 'es-ES'
|
|
149
|
+
* });
|
|
150
|
+
* console.log('Spanish available:', isAvailable);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
isLanguageAvailable(options: IsLanguageAvailableOptions): Promise<{
|
|
154
|
+
isAvailable: boolean;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Checks if a specific voice is available.
|
|
158
|
+
*
|
|
159
|
+
* @param options - The voice ID to check
|
|
160
|
+
* @returns Promise resolving with the availability status
|
|
161
|
+
* @since 1.0.0
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const { isAvailable } = await SpeechSynthesis.isVoiceAvailable({
|
|
165
|
+
* voiceId: 'com.apple.ttsbundle.Samantha-compact'
|
|
166
|
+
* });
|
|
167
|
+
* console.log('Voice available:', isAvailable);
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
isVoiceAvailable(options: IsVoiceAvailableOptions): Promise<{
|
|
171
|
+
isAvailable: boolean;
|
|
172
|
+
}>;
|
|
173
|
+
/**
|
|
174
|
+
* Initializes the speech synthesis engine (iOS optimization).
|
|
175
|
+
* This can reduce latency for the first speech request.
|
|
176
|
+
*
|
|
177
|
+
* @returns Promise that resolves when initialized
|
|
178
|
+
* @since 1.0.0
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* await SpeechSynthesis.initialize();
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
initialize(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Activates the audio session with a specific category (iOS only).
|
|
187
|
+
*
|
|
188
|
+
* @param options - The audio session category
|
|
189
|
+
* @returns Promise that resolves when activated
|
|
190
|
+
* @since 1.0.0
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* await SpeechSynthesis.activateAudioSession({
|
|
194
|
+
* category: 'Playback'
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
activateAudioSession(options: ActivateAudioSessionOptions): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Deactivates the audio session (iOS only).
|
|
201
|
+
*
|
|
202
|
+
* @returns Promise that resolves when deactivated
|
|
203
|
+
* @since 1.0.0
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* await SpeechSynthesis.deactivateAudioSession();
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
deactivateAudioSession(): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Gets the native plugin version.
|
|
212
|
+
*
|
|
213
|
+
* @returns Promise resolving with the plugin version
|
|
214
|
+
* @since 1.0.0
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* const { version } = await SpeechSynthesis.getPluginVersion();
|
|
218
|
+
* console.log('Plugin version:', version);
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
getPluginVersion(): Promise<{
|
|
222
|
+
version: string;
|
|
223
|
+
}>;
|
|
224
|
+
/**
|
|
225
|
+
* Listens for when an utterance starts speaking.
|
|
226
|
+
*
|
|
227
|
+
* @param eventName - The event name ('start')
|
|
228
|
+
* @param listenerFunc - The callback function
|
|
229
|
+
* @returns A handle to remove the listener
|
|
230
|
+
* @since 1.0.0
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* const listener = await SpeechSynthesis.addListener('start', (event) => {
|
|
234
|
+
* console.log('Started speaking:', event.utteranceId);
|
|
235
|
+
* });
|
|
236
|
+
* // Later: listener.remove();
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
addListener(eventName: 'start', listenerFunc: (event: UtteranceEvent) => void): Promise<PluginListenerHandle>;
|
|
240
|
+
/**
|
|
241
|
+
* Listens for when an utterance finishes speaking.
|
|
242
|
+
*
|
|
243
|
+
* @param eventName - The event name ('end')
|
|
244
|
+
* @param listenerFunc - The callback function
|
|
245
|
+
* @returns A handle to remove the listener
|
|
246
|
+
* @since 1.0.0
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* const listener = await SpeechSynthesis.addListener('end', (event) => {
|
|
250
|
+
* console.log('Finished speaking:', event.utteranceId);
|
|
251
|
+
* });
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
addListener(eventName: 'end', listenerFunc: (event: UtteranceEvent) => void): Promise<PluginListenerHandle>;
|
|
255
|
+
/**
|
|
256
|
+
* Listens for word boundaries during speech.
|
|
257
|
+
*
|
|
258
|
+
* @param eventName - The event name ('boundary')
|
|
259
|
+
* @param listenerFunc - The callback function
|
|
260
|
+
* @returns A handle to remove the listener
|
|
261
|
+
* @since 1.0.0
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* const listener = await SpeechSynthesis.addListener('boundary', (event) => {
|
|
265
|
+
* console.log('Word boundary at:', event.charIndex);
|
|
266
|
+
* });
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
addListener(eventName: 'boundary', listenerFunc: (event: BoundaryEvent) => void): Promise<PluginListenerHandle>;
|
|
270
|
+
/**
|
|
271
|
+
* Listens for synthesis errors.
|
|
272
|
+
*
|
|
273
|
+
* @param eventName - The event name ('error')
|
|
274
|
+
* @param listenerFunc - The callback function
|
|
275
|
+
* @returns A handle to remove the listener
|
|
276
|
+
* @since 1.0.0
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* const listener = await SpeechSynthesis.addListener('error', (event) => {
|
|
280
|
+
* console.error('Speech error:', event.error);
|
|
281
|
+
* });
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
addListener(eventName: 'error', listenerFunc: (event: ErrorEvent) => void): Promise<PluginListenerHandle>;
|
|
285
|
+
/**
|
|
286
|
+
* Removes all event listeners.
|
|
287
|
+
*
|
|
288
|
+
* @returns Promise that resolves when listeners are removed
|
|
289
|
+
* @since 1.0.0
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* await SpeechSynthesis.removeAllListeners();
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
removeAllListeners(): Promise<void>;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Options for speaking text.
|
|
299
|
+
*
|
|
300
|
+
* @since 1.0.0
|
|
301
|
+
*/
|
|
302
|
+
export interface SpeakOptions {
|
|
303
|
+
/**
|
|
304
|
+
* The text to speak.
|
|
305
|
+
*
|
|
306
|
+
* @since 1.0.0
|
|
307
|
+
*/
|
|
308
|
+
text: string;
|
|
309
|
+
/**
|
|
310
|
+
* The BCP-47 language tag (e.g., 'en-US', 'es-ES').
|
|
311
|
+
*
|
|
312
|
+
* @since 1.0.0
|
|
313
|
+
*/
|
|
314
|
+
language?: string;
|
|
315
|
+
/**
|
|
316
|
+
* The voice identifier to use.
|
|
317
|
+
*
|
|
318
|
+
* @since 1.0.0
|
|
319
|
+
*/
|
|
320
|
+
voiceId?: string;
|
|
321
|
+
/**
|
|
322
|
+
* The pitch of the voice (0.5 to 2.0, default: 1.0).
|
|
323
|
+
*
|
|
324
|
+
* @since 1.0.0
|
|
325
|
+
*/
|
|
326
|
+
pitch?: number;
|
|
327
|
+
/**
|
|
328
|
+
* The speaking rate (0.1 to 10.0, default: 1.0).
|
|
329
|
+
*
|
|
330
|
+
* @since 1.0.0
|
|
331
|
+
*/
|
|
332
|
+
rate?: number;
|
|
333
|
+
/**
|
|
334
|
+
* The volume (0.0 to 1.0, default: 1.0).
|
|
335
|
+
*
|
|
336
|
+
* @since 1.0.0
|
|
337
|
+
*/
|
|
338
|
+
volume?: number;
|
|
339
|
+
/**
|
|
340
|
+
* The queue strategy: 'Add' to append or 'Flush' to replace queue.
|
|
341
|
+
* Default: 'Add'
|
|
342
|
+
*
|
|
343
|
+
* @since 1.0.0
|
|
344
|
+
*/
|
|
345
|
+
queueStrategy?: 'Add' | 'Flush';
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Result from speaking text.
|
|
349
|
+
*
|
|
350
|
+
* @since 1.0.0
|
|
351
|
+
*/
|
|
352
|
+
export interface SpeakResult {
|
|
353
|
+
/**
|
|
354
|
+
* Unique identifier for this utterance.
|
|
355
|
+
*
|
|
356
|
+
* @since 1.0.0
|
|
357
|
+
*/
|
|
358
|
+
utteranceId: string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Result from synthesizing to file.
|
|
362
|
+
*
|
|
363
|
+
* @since 1.0.0
|
|
364
|
+
*/
|
|
365
|
+
export interface SynthesizeToFileResult {
|
|
366
|
+
/**
|
|
367
|
+
* The file path where audio was saved.
|
|
368
|
+
*
|
|
369
|
+
* @since 1.0.0
|
|
370
|
+
*/
|
|
371
|
+
filePath: string;
|
|
372
|
+
/**
|
|
373
|
+
* Unique identifier for this utterance.
|
|
374
|
+
*
|
|
375
|
+
* @since 1.0.0
|
|
376
|
+
*/
|
|
377
|
+
utteranceId: string;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Information about a voice.
|
|
381
|
+
*
|
|
382
|
+
* @since 1.0.0
|
|
383
|
+
*/
|
|
384
|
+
export interface VoiceInfo {
|
|
385
|
+
/**
|
|
386
|
+
* Unique voice identifier.
|
|
387
|
+
*
|
|
388
|
+
* @since 1.0.0
|
|
389
|
+
*/
|
|
390
|
+
id: string;
|
|
391
|
+
/**
|
|
392
|
+
* Display name of the voice.
|
|
393
|
+
*
|
|
394
|
+
* @since 1.0.0
|
|
395
|
+
*/
|
|
396
|
+
name: string;
|
|
397
|
+
/**
|
|
398
|
+
* BCP-47 language code.
|
|
399
|
+
*
|
|
400
|
+
* @since 1.0.0
|
|
401
|
+
*/
|
|
402
|
+
language: string;
|
|
403
|
+
/**
|
|
404
|
+
* Gender of the voice (iOS only).
|
|
405
|
+
*
|
|
406
|
+
* @since 1.0.0
|
|
407
|
+
*/
|
|
408
|
+
gender?: 'male' | 'female' | 'neutral';
|
|
409
|
+
/**
|
|
410
|
+
* Whether this voice requires a network connection.
|
|
411
|
+
*
|
|
412
|
+
* @since 1.0.0
|
|
413
|
+
*/
|
|
414
|
+
isNetworkConnectionRequired?: boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Whether this is the default voice (Web only).
|
|
417
|
+
*
|
|
418
|
+
* @since 1.0.0
|
|
419
|
+
*/
|
|
420
|
+
default?: boolean;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Options for checking language availability.
|
|
424
|
+
*
|
|
425
|
+
* @since 1.0.0
|
|
426
|
+
*/
|
|
427
|
+
export interface IsLanguageAvailableOptions {
|
|
428
|
+
/**
|
|
429
|
+
* The BCP-47 language code to check.
|
|
430
|
+
*
|
|
431
|
+
* @since 1.0.0
|
|
432
|
+
*/
|
|
433
|
+
language: string;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Options for checking voice availability.
|
|
437
|
+
*
|
|
438
|
+
* @since 1.0.0
|
|
439
|
+
*/
|
|
440
|
+
export interface IsVoiceAvailableOptions {
|
|
441
|
+
/**
|
|
442
|
+
* The voice ID to check.
|
|
443
|
+
*
|
|
444
|
+
* @since 1.0.0
|
|
445
|
+
*/
|
|
446
|
+
voiceId: string;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Options for activating the audio session (iOS only).
|
|
450
|
+
*
|
|
451
|
+
* @since 1.0.0
|
|
452
|
+
*/
|
|
453
|
+
export interface ActivateAudioSessionOptions {
|
|
454
|
+
/**
|
|
455
|
+
* The audio session category.
|
|
456
|
+
* - 'Ambient': Mixes with other audio
|
|
457
|
+
* - 'Playback': Stops other audio
|
|
458
|
+
*
|
|
459
|
+
* @since 1.0.0
|
|
460
|
+
*/
|
|
461
|
+
category: 'Ambient' | 'Playback';
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Event emitted when utterance starts or ends.
|
|
465
|
+
*
|
|
466
|
+
* @since 1.0.0
|
|
467
|
+
*/
|
|
468
|
+
export interface UtteranceEvent {
|
|
469
|
+
/**
|
|
470
|
+
* The utterance identifier.
|
|
471
|
+
*
|
|
472
|
+
* @since 1.0.0
|
|
473
|
+
*/
|
|
474
|
+
utteranceId: string;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Event emitted at word boundaries.
|
|
478
|
+
*
|
|
479
|
+
* @since 1.0.0
|
|
480
|
+
*/
|
|
481
|
+
export interface BoundaryEvent {
|
|
482
|
+
/**
|
|
483
|
+
* The utterance identifier.
|
|
484
|
+
*
|
|
485
|
+
* @since 1.0.0
|
|
486
|
+
*/
|
|
487
|
+
utteranceId: string;
|
|
488
|
+
/**
|
|
489
|
+
* The character index in the text.
|
|
490
|
+
*
|
|
491
|
+
* @since 1.0.0
|
|
492
|
+
*/
|
|
493
|
+
charIndex: number;
|
|
494
|
+
/**
|
|
495
|
+
* The character length of the current word.
|
|
496
|
+
*
|
|
497
|
+
* @since 1.0.0
|
|
498
|
+
*/
|
|
499
|
+
charLength?: number;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Event emitted on synthesis error.
|
|
503
|
+
*
|
|
504
|
+
* @since 1.0.0
|
|
505
|
+
*/
|
|
506
|
+
export interface ErrorEvent {
|
|
507
|
+
/**
|
|
508
|
+
* The utterance identifier.
|
|
509
|
+
*
|
|
510
|
+
* @since 1.0.0
|
|
511
|
+
*/
|
|
512
|
+
utteranceId: string;
|
|
513
|
+
/**
|
|
514
|
+
* The error message.
|
|
515
|
+
*
|
|
516
|
+
* @since 1.0.0
|
|
517
|
+
*/
|
|
518
|
+
error: string;
|
|
519
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const SpeechSynthesis = registerPlugin('SpeechSynthesis', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.SpeechSynthesisWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { SpeechSynthesis };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,eAAe,GAAG,cAAc,CAAwB,iBAAiB,EAAE;IAC/E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;CACnE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { SpeechSynthesisPlugin, SpeakOptions, SpeakResult, SynthesizeToFileResult, VoiceInfo, IsLanguageAvailableOptions, IsVoiceAvailableOptions, ActivateAudioSessionOptions } from './definitions';
|
|
3
|
+
export declare class SpeechSynthesisWeb extends WebPlugin implements SpeechSynthesisPlugin {
|
|
4
|
+
private utteranceIdCounter;
|
|
5
|
+
private currentUtterances;
|
|
6
|
+
speak(options: SpeakOptions): Promise<SpeakResult>;
|
|
7
|
+
synthesizeToFile(_options: SpeakOptions): Promise<SynthesizeToFileResult>;
|
|
8
|
+
cancel(): Promise<void>;
|
|
9
|
+
pause(): Promise<void>;
|
|
10
|
+
resume(): Promise<void>;
|
|
11
|
+
isSpeaking(): Promise<{
|
|
12
|
+
isSpeaking: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
isAvailable(): Promise<{
|
|
15
|
+
isAvailable: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
getVoices(): Promise<{
|
|
18
|
+
voices: VoiceInfo[];
|
|
19
|
+
}>;
|
|
20
|
+
getLanguages(): Promise<{
|
|
21
|
+
languages: string[];
|
|
22
|
+
}>;
|
|
23
|
+
isLanguageAvailable(options: IsLanguageAvailableOptions): Promise<{
|
|
24
|
+
isAvailable: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
isVoiceAvailable(options: IsVoiceAvailableOptions): Promise<{
|
|
27
|
+
isAvailable: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
initialize(): Promise<void>;
|
|
30
|
+
activateAudioSession(_options: ActivateAudioSessionOptions): Promise<void>;
|
|
31
|
+
deactivateAudioSession(): Promise<void>;
|
|
32
|
+
getPluginVersion(): Promise<{
|
|
33
|
+
version: string;
|
|
34
|
+
}>;
|
|
35
|
+
}
|