2016-08-16 12:53:15 +08:00
|
|
|
import { Plugin, Cordova } from './plugin';
|
2016-08-15 21:29:51 +08:00
|
|
|
|
|
|
|
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
|
2016-08-15 21:29:51 +08:00
|
|
|
* @description
|
|
|
|
* Text to Speech plugin
|
|
|
|
*
|
|
|
|
* @usage
|
|
|
|
* ```
|
2016-09-01 04:59:41 +08:00
|
|
|
* import {TextToSpeech} from 'ionic-native';
|
2016-08-15 21:29:51 +08:00
|
|
|
*
|
2016-09-01 04:59:41 +08:00
|
|
|
* TextToSpeech.speak('Hello World')
|
2016-08-15 21:29:51 +08:00
|
|
|
* .then(() => console.log('Success'))
|
|
|
|
* .catch((reason: any) => console.log(reason));
|
|
|
|
*
|
|
|
|
* ```
|
2016-12-06 22:52:39 +08:00
|
|
|
* @interfaces
|
|
|
|
* TTSOptions
|
2016-08-15 21:29:51 +08:00
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-10-28 01:48:50 +08:00
|
|
|
pluginName: 'TextToSpeech',
|
2016-08-15 21:29:51 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-03-02 10:01:39 +08:00
|
|
|
static stop(): Promise<any> {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-15 21:29:51 +08:00
|
|
|
}
|