Text to speech (Inoic 2)


#1

Hello! I have a problem using this plugin:

My code is like this:

  TTS.speak({
        text: 'hello, world!',
        locale: 'en-GB',
        rate: 0.75
    }, function () {
        alert('success');
    }, function (reason) {
        alert(reason);
    });

and the problem is: “Cannot find name ‘TTS’.” . I have installed the plugin like this: “cordova plugin add cordova-plugin-tts”. Somebody know how can I solve it?
Thanks in advance.

Best regards!


#2

first import the plugin
import {TextToSpeech} from ‘ionic-native’;

in your function use this :
TextToSpeech.speak(options)
.then(() => console.log(‘Success’))
.catch((reason: any) => console.log(reason));

the problem is only TTS is not declare before…