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);
});
});
}
...
CodePudding user response:
$("#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>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>