mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-05-02 00:07:23 +08:00
feat(TTS): add tts plugin (#431)
* Initial Pass at TTS * Rename and fix index * Remove unnecessary window in reference closes #311
This commit is contained in:
committed by
Ibrahim Hadeed
parent
b4158f4f85
commit
dcf3ab2787
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user