awesome-cordova-plugins/src/plugins/text-to-speech.ts

49 lines
1.0 KiB
TypeScript
Raw Normal View History

2016-08-16 12:53:15 +08:00
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;
}
/**
2016-09-01 04:59:41 +08:00
* @name TextToSpeech
* @description
* Text to Speech plugin
*
* @usage
* ```
2016-09-01 04:59:41 +08:00
* import {TextToSpeech} from 'ionic-native';
*
2016-09-01 04:59:41 +08:00
* TextToSpeech.speak('Hello World')
* .then(() => console.log('Success'))
* .catch((reason: any) => console.log(reason));
*
* ```
*/
@Plugin({
pluginName: 'TextToSpeech',
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;
}
}