Text To Speech
Text to Speech plugin
Repo: https://github.com/vilic/cordova-plugin-tts
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-tts $ npm install --save @ionic-native/text-to-speech@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
- Windows Phone 8
Usage
import { TextToSpeech } from '@ionic-native/text-to-speech';
constructor(private tts: TextToSpeech) { }
...
this.tts.speak('Hello World')
.then(() => console.log('Success'))
.catch((reason: any) => console.log(reason));
Instance Members
speak(textOrOptions)
This function speaks
Param | Type | Details |
---|---|---|
textOrOptions |
string |TTSOptions
|
Text to speak or TTSOptions |
Returns: Promise<any>
Returns a promise that resolves when the speaking finishes
stop()
Stop any current TTS playback
Returns: Promise<any>
TTSOptions
Param | Type | Details |
---|---|---|
text |
string
|
text to speak |
locale |
string
|
a string like 'en-US', 'zh-CN', etc (optional) |
rate |
number
|
speed rate, 0 ~ 1 (optional) |