You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
locale:'en-GB', // optional - default is system locale,
45
-
finishedCallback:Function, // optional
39
+
text:'Whatever you like', /// *** required ***
40
+
speakRate:0.5, // optional - default is 1.0
41
+
pitch:1.0, // optional - default is 1.0
42
+
volume:1.0, // optional - default is 1.0
43
+
locale:'en-GB', // optional - default is system locale,
44
+
finishedCallback:Function, // optional
46
45
};
47
46
48
47
// Call the `speak` method passing the SpeakOptions object
49
48
TTS.speak(speakOptions).then(
50
-
() => {
51
-
// everything is fine
52
-
},
53
-
(err) => {
54
-
// oops, something went wrong!
55
-
}
49
+
() => {
50
+
// everything is fine
51
+
},
52
+
(err) => {
53
+
// oops, something went wrong!
54
+
}
56
55
);
57
56
```
58
57
59
58
#### API
60
59
61
-
-`speak(options: SpeakOptions): Promise<any>` - start speaking with the given options
62
-
-`pause(): void` - pause the speech
63
-
-`resume(): void` - resume the speech
64
-
-`destroy(): void` - release resources for the speech synthesizer/engine
65
-
66
-
-`SpeakOptions = {}`
67
-
-`text: string`** required **
68
-
-`queue?: boolean = false`
69
-
-`pitch?: number = 1.0`
70
-
-`speakRate?: number = 1.0`
71
-
-`volume?: number = 1.0`
72
-
-`locale?: string = default system locale`
73
-
-`language?: string = default system language`** Android only **
74
-
-`finishedCallback?: Function`
60
+
-`speak(options: SpeakOptions): Promise<any>` - start speaking with the given options
61
+
-`pause(): void` - pause the speech
62
+
-`resume(): void` - resume the speech
63
+
-`destroy(): void` - release resources for the speech synthesizer/engine
64
+
65
+
-`SpeakOptions = {}`
66
+
-`text: string`** required **
67
+
-`queue?: boolean = false`
68
+
-`pitch?: number = 1.0`
69
+
-`speakRate?: number = 1.0`
70
+
-`volume?: number = 1.0`
71
+
-`locale?: string = default system locale`
72
+
-`language?: string = default system language`** Android only **
73
+
-`finishedCallback?: Function`
75
74
76
75
If you wish to set a custom locale, you need to provide a valid BCP-47 code, e.g. `en-US`. If you wish to set only a custom language (without a preferred country code), you need to provide a valid ISO 639-1 language code. If both are set, the custom locale will be used.
77
76
@@ -81,28 +80,28 @@ Example with language code only:
81
80
82
81
```js
83
82
const speakOptions:SpeakOptions= {
84
-
text:'Whatever you like', // *** required ***
85
-
language:'en', // english language will be used
83
+
text:'Whatever you like', // *** required ***
84
+
language:'en', // english language will be used
86
85
};
87
86
```
88
87
89
88
Example with locale:
90
89
91
90
```js
92
91
const speakOptions:SpeakOptions= {
93
-
text:'Whatever you like', // *** required ***
94
-
locale:'en-AU', // australian english language will be used
92
+
text:'Whatever you like', // *** required ***
93
+
locale:'en-AU', // australian english language will be used
95
94
};
96
95
```
97
96
98
97
### Tip
99
98
100
-
- The speech synthesizer takes a moment to initialize on most devices. A simple way to get around this (tested in the demo app) is to create your new instance of the TNSTextToSpeech and then immediately call the `init` method . This will force the synthesizer to "warm up" . Now when you call the `speak` method for your app's functionality it will already have "warmed up" the synthesizer so the delay should be minimal.
101
-
It's possible this "Warm up" process could be put into the plugin source itself, I don't have time to do it right now but welcome any contribution that is well tested to make this the default behavior of the synthesizers.
99
+
-The speech synthesizer takes a moment to initialize on most devices. A simple way to get around this (tested in the demo app) is to create your new instance of the TNSTextToSpeech and then immediately call the `init` method . This will force the synthesizer to "warm up" . Now when you call the `speak` method for your app's functionality it will already have "warmed up" the synthesizer so the delay should be minimal.
100
+
It's possible this "Warm up" process could be put into the plugin source itself, I don't have time to do it right now but welcome any contribution that is well tested to make this the default behavior of the synthesizers.
102
101
103
102
### Android Only Methods
104
103
105
-
-`getAvailableLanguages(): Promise<Array<Language>>;` - returns an array of available languages (use to prevent using non-existing language/local codes)
104
+
-`getAvailableLanguages(): Promise<Array<Language>>;` - returns an array of available languages (use to prevent using non-existing language/local codes)
0 commit comments