简体   繁体   English

Cordova 文字转语音

[英]Cordova Text-to-speech

I am new to the android platform.我是 android 平台的新手。 Now I am working on TTS(Text to Speech) in cordova.现在我正在 cordova 中研究 TTS(文本到语音)。 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.我想在 TextArea 中键入文本,并且希望在单击发言按钮时将其转换为语音。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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