简体   繁体   中英

Cordova Text-to-speech

I am new to the android platform. Now I am working on TTS(Text to Speech) in cordova. i've search in here for solution but almost all of it didnt work. I want type the text in a TextArea and I would like it to be converted to speech when i click the speak button. sorry for my confusing words, I'm struggling to explain the problems I'm having and English isn't my main language. Can anyone help me out? Thanks in advance.

here my code...

function speech() {
        var result = document.getElementById("result");
        document.addEventListener('deviceready', function () {
            // Speak some text
            TTS.speak({
                text: "result",
                locale: 'en-GB',
                rate: 0.75
            }, function () {
                console.log('success');
            }, function (reason) {
                console.log(reason);
            });
        });
    }

...

 $("#click").on("click", function () { var txtVal = $("#txtSpeak").val(); console.log(txtVal); TTS.speak( { text: txtVal, locale: "en-GB", rate: 0.75, }, function () { console.log("success"); }, function (reason) { console.log(reason); } ); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <textarea id="txtSpeak"></textarea> <br /> <button id="click"> Click </button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM