Phonegap TTS Plugin Android not working

后端 未结 2 489
鱼传尺愫
鱼传尺愫 2021-02-04 19:12

I am using the TTS Plugin from https://github.com/domaemon/org.apache.cordova.plugin.tts But the plugin does not seem to work. It does not even initialize.

Installed the

2条回答
  •  北海茫月
    2021-02-04 19:33

    After some struggle i have the TTS working. But there is still one issue i had to manually fix. Following are the steps to get the TTS Working

    Install the plugin like below.

    phonegap plugin add https://github.com/domaemon/org.apache.cordova.plugin.tts.git
    phonegap build android
    

    Once installed and built. Add this plugin to the phonegap config.xml file. ( If you are building the app using sencha touch, the config.xml will be in the root folder. )

    
    

    This will add the plugin to the final build. Now to start the TTS Service and speak some text, use the following snippet.

    navigator.tts.startup(startupWin, fail);
    function startupWin(result) {
        console.log("Startup win");
        // When result is equal to STARTED we are ready to play
        console.log("Result "+result);
        //TTS.STARTED==2 use this once so is answered
        if (result == 2) {
            navigator.tts.getLanguage(win, fail);
            navigator.tts.speak("The text to speech service is ready");                                     
        }
    }                               
    
    function win(result) {
        console.log(result);
    }
    
    function fail(result) {
        console.log("Error = " + result);
    }
    

    The issue i had was the TTS.STARTED in the startupWin is not defined in the plugin. I just used the constant's value and the plugin works perfectly.

提交回复
热议问题