From b55a249ba0dba81829475a0ef4144e3940c41c77 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Fri, 19 Feb 2021 10:34:28 +0100 Subject: [PATCH 1/5] Text to speech advanced plugin --- .../plugins/text-to-speech-advanced/index.ts | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/@ionic-native/plugins/text-to-speech-advanced/index.ts diff --git a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts new file mode 100644 index 0000000000..13591623bd --- /dev/null +++ b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts @@ -0,0 +1,88 @@ +import { Injectable } from '@angular/core'; +import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; + +export interface TTSOptions { + /** text to speak */ + text: string; + /** cancel, boolean: true/false */ + identifier: string; + /** voice identifier (iOS / Android) from getVoices */ + locale?: string; + /** speed rate, 0 ~ 1 */ + rate?: number; + /** pitch, 0 ~ 1 */ + pitch?: number; + /** cancel, boolean: true/false */ + cancel?: boolean; +} + +export interface TTSVoice { + /** Voice name */ + name: string; + /** Language **/ + language: string; + /** Voice identifier string */ + identifier: string; +} + +/** + * @name Text To Speech + * @description + * Text to Speech plugin + * + * @usage + * ```typescript + * import { TextToSpeech } from '@ionic-native/text-to-speech/ngx'; + * + * 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 Advanced', + plugin: 'cordova-plugin-tts-advanced', + pluginRef: 'TTS', + repo: 'https://github.com/spasma/cordova-plugin-tts-advanced', + platforms: ['Android', 'iOS'], +}) +@Injectable() +export class TextToSpeechAdvanced extends IonicNativePlugin { + /** + * This function speaks + * @param textOrOptions {string | TTSOptions} Text to speak or TTSOptions + * @return {Promise} Returns a promise that resolves when the speaking finishes + */ + @Cordova({ + successIndex: 1, + errorIndex: 2, + }) + speak(textOrOptions: string | TTSOptions): Promise { + return; + } + + /** + * Stop any current TTS playback + * @return {Promise} + */ + @Cordova() + stop(): Promise { + return; + } + + /** + * Get all voices + * @return {Promise} + */ + @Cordova() + getVoices(): Promise { + return; + } +} From 75c572f048f99989eab7fc84ab059d563f810eef Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Fri, 19 Feb 2021 10:39:22 +0100 Subject: [PATCH 2/5] Add @interface --- src/@ionic-native/plugins/text-to-speech-advanced/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts index 13591623bd..80eb2da74b 100644 --- a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts +++ b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts @@ -45,6 +45,7 @@ export interface TTSVoice { * ``` * @interfaces * TTSOptions + * TTSVoice */ @Plugin({ pluginName: 'Text To Speech Advanced', From 01c2a5b1907b3967f8f3f7a4388618e834805346 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 23 Feb 2021 13:21:11 +0100 Subject: [PATCH 3/5] docs update --- src/@ionic-native/plugins/text-to-speech-advanced/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts index 80eb2da74b..f2925c30d6 100644 --- a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts +++ b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts @@ -26,15 +26,15 @@ export interface TTSVoice { } /** - * @name Text To Speech + * @name Text To Speech Advanced * @description * Text to Speech plugin * * @usage * ```typescript - * import { TextToSpeech } from '@ionic-native/text-to-speech/ngx'; + * import { TextToSpeechAdvanced } from '@ionic-native/text-to-speech-advanced/ngx'; * - * constructor(private tts: TextToSpeech) { } + * constructor(private tts: TextToSpeechAdvanced) { } * * ... * From ddd90b8ed522df027726e41cfa6418c56d20ab16 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 23 Feb 2021 13:24:01 +0100 Subject: [PATCH 4/5] jsdoc fix --- src/@ionic-native/plugins/text-to-speech-advanced/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts index f2925c30d6..b0f572b15e 100644 --- a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts +++ b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts @@ -19,7 +19,7 @@ export interface TTSOptions { export interface TTSVoice { /** Voice name */ name: string; - /** Language **/ + /** Voice language **/ language: string; /** Voice identifier string */ identifier: string; From 5bece9c0c13ccb5c867313b1383a4f5b819ad938 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Tue, 23 Feb 2021 13:25:45 +0100 Subject: [PATCH 5/5] jsdoc fix --- src/@ionic-native/plugins/text-to-speech-advanced/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts index b0f572b15e..c021b8acfc 100644 --- a/src/@ionic-native/plugins/text-to-speech-advanced/index.ts +++ b/src/@ionic-native/plugins/text-to-speech-advanced/index.ts @@ -19,7 +19,7 @@ export interface TTSOptions { export interface TTSVoice { /** Voice name */ name: string; - /** Voice language **/ + /** Voice language */ language: string; /** Voice identifier string */ identifier: string;