Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TTS): add tts plugin #431

Merged
merged 3 commits into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {StatusBar} from './plugins/statusbar';
import {ThreeDeeTouch} from './plugins/3dtouch';
import {Toast} from './plugins/toast';
import {TouchID} from './plugins/touchid';
import {TextToSpeech} from './plugins/text-to-speech';
import {TwitterConnect} from './plugins/twitter-connect';
import {Vibration} from './plugins/vibration';
import {VideoPlayer} from './plugins/video-player';
Expand Down Expand Up @@ -166,6 +167,7 @@ export {
StatusBar,
TouchID,
Transfer,
TextToSpeech,
Vibration,
WebIntent,
Zip
Expand Down Expand Up @@ -250,6 +252,7 @@ window['IonicNative'] = {
Toast: Toast,
TouchID: TouchID,
Transfer: Transfer,
TextToSpeech: TextToSpeech,
TwitterConnect: TwitterConnect,
VideoPlayer: VideoPlayer,
Vibration: Vibration,
Expand Down
47 changes: 47 additions & 0 deletions src/plugins/text-to-speech.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {Plugin, Cordova} from './plugin';

export interface TTSOptions {
/** text to speak */
text: string;
/** a string like 'en-US', 'zh-CN', etc */
locale?: string;
/** speed rate, 0 ~ 1 */
rate?: number;
}

/**
* @name TTS
* @description
* Text to Speech plugin
*
* @usage
* ```
* import {TTS} from 'ionic-native';
*
* TTS.speak('Hello World')
* .then(() => console.log('Success'))
* .catch((reason: any) => console.log(reason));
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-tts',
pluginRef: 'TTS',
repo: 'https://github.com/vilic/cordova-plugin-tts'
})
export class TextToSpeech {

/**
* This function speaks
* @param options {string | TTSOptions} Text to speak or TTSOptions
* @return {Promise<any>} Returns a promise that resolves when the speaking finishes
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static speak(options: string | TTSOptions): Promise<any> {
return;
}

}