mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-04-13 00:00:10 +08:00
c6f9fa356f
* typo(barcode-scanner): fixe circle lint error
* typo(docs): Unified the documentations
In some plugins the typescript markup was missing.
I also unified the console.log string from console.log("hello") to console.log('Hello') so any plugin page look the same.
66 lines
1.3 KiB
TypeScript
66 lines
1.3 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
|
|
|
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 Text To Speech
|
|
* @description
|
|
* Text to Speech plugin
|
|
*
|
|
* @usage
|
|
* ```typescript
|
|
* 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));
|
|
*
|
|
* ```
|
|
* @interfaces
|
|
* TTSOptions
|
|
*/
|
|
@Plugin({
|
|
pluginName: 'Text To Speech',
|
|
plugin: 'cordova-plugin-tts',
|
|
pluginRef: 'TTS',
|
|
repo: 'https://github.com/vilic/cordova-plugin-tts'
|
|
})
|
|
@Injectable()
|
|
export class TextToSpeech extends IonicNativePlugin {
|
|
|
|
/**
|
|
* 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
|
|
})
|
|
speak(options: string | TTSOptions): Promise<any> {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Stop any current TTS playback
|
|
* @return {Promise<any>}
|
|
*/
|
|
@Cordova()
|
|
stop(): Promise<any> {
|
|
return;
|
|
}
|
|
|
|
}
|