Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot get Cordova text-to-speech plugin to work

I'm trying various plugins for TTS, including the one at https://github.com/vilic/cordova-plugin-tts, but cannot get any to work. For this one, for example, according to the docs, its usage should be:

    TTS
    .speak('hello, world!', function () {
        alert('success');
    }, function (reason) {
        alert(reason);
    });

but I get 'TTS not defined'. Also tried 'navigator.TTS....' but still no good. Also I'm unsure whether I need to include the tts.js in the package; if so I get 'exports not defined'. If anyone is successfully using this plugin, please can you put me in the correct direction? Or if there's an alternative plugin that works, I could use that, but many TTS plugins on GitHub appear unsupported for 3-4 years. BTW other plugins I am using (e.g. geolocation) are working fine

like image 490
quilkin Avatar asked Oct 31 '22 01:10

quilkin


1 Answers

Have now solved this. I didn't have <script src="cordova.js"></script> in my index.html. This was also stopping 'onDeviceReady' from firing, which is how I came about solving it. So it seems you need this script included for some plugins but not for others. How confusing. Can I claim back my 50 bonus points for solving it myself? ;)

like image 83
quilkin Avatar answered Jan 04 '23 15:01

quilkin