Skip to content

Commit dbd0f66

Browse files
committed
Merge branch 'master' of github.com:nativescript-community/texttospeech
2 parents 104e94e + 9cf631e commit dbd0f66

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

README.md

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
[![npm](https://img.shields.io/npm/v/nativescript-community/texttospeech.svg)](https://www.npmjs.com/package/nativescript-community/texttospeech)
2-
[![npm](https://img.shields.io/npm/dt/nativescript-community/texttospeech.svg?label=npm%20downloads)](https://www.npmjs.com/package/nativescript-community/texttospeech)
1+
[![npm](https://img.shields.io/npm/v/@nativescript-community/texttospeech.svg)](https://www.npmjs.com/package/@nativescript-community/texttospeech)
2+
[![npm](https://img.shields.io/npm/dt/@nativescript-community/texttospeech.svg?label=npm%20downloads)](https://www.npmjs.com/package/@nativescript-community/texttospeech)
33

44
# @nativescript-community/texttospeech :loudspeaker:
55

66
A Text to Speech NativeScript plugin for Android & iOS
77

88
#### Native Controls
99

10-
- Android - [TextToSpeech](https://developer.android.com/reference/android/speech/tts/TextToSpeech.html)
11-
- iOS - [AVSpeechSynthesizer](https://developer.apple.com/reference/avfoundation/avspeechsynthesizer)
10+
- Android - [TextToSpeech](https://developer.android.com/reference/android/speech/tts/TextToSpeech.html)
11+
- iOS - [AVSpeechSynthesizer](https://developer.apple.com/reference/avfoundation/avspeechsynthesizer)
1212

1313
## Installation
1414

1515
Run the following command from the root of your project:
1616

17-
1817
```
1918
tns plugin add @nativescript-community/texttospeech
2019
```
@@ -37,41 +36,41 @@ import { TNSTextToSpeech, SpeakOptions } from '@nativescript-community/texttospe
3736
const TTS = new TNSTextToSpeech();
3837

3938
const speakOptions: SpeakOptions = {
40-
text: 'Whatever you like', /// *** required ***
41-
speakRate: 0.5, // optional - default is 1.0
42-
pitch: 1.0, // optional - default is 1.0
43-
volume: 1.0, // optional - default is 1.0
44-
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
4645
};
4746

4847
// Call the `speak` method passing the SpeakOptions object
4948
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+
}
5655
);
5756
```
5857

5958
#### API
6059

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`
7574

7675
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.
7776

@@ -81,28 +80,28 @@ Example with language code only:
8180

8281
```js
8382
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
8685
};
8786
```
8887

8988
Example with locale:
9089

9190
```js
9291
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
9594
};
9695
```
9796

9897
### Tip
9998

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.
102101

103102
### Android Only Methods
104103

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)
106105

107106
## Credits
108107

0 commit comments

Comments
 (0)