cordova-plugin-tts icon indicating copy to clipboard operation
cordova-plugin-tts copied to clipboard

TTS is not working with long string 5000 characters

Open dmiepub opened this issue 7 years ago • 3 comments

Trying to use TTS.tts and passing a long string approx 5000 characters but it is not speaking while shortening the string with less than 4000 characters, it is speaking the text.

$scope.speakText = function(text) { console.log(text); console.log($scope.data[text]); $scope.showSpeakBtn = false; $scope.showStopBtn = true;

if (window.cordova) { TTS.speak({ text: $scope.data[text], locale: ‘en-US’, rate: 1.0 }, function () {

   // Do Something after success

}, function (reason) { // Handle the error case }); } }

Please suggest how to resolve this.

dmiepub avatar Mar 10 '18 08:03 dmiepub

You can cut the chain and chain the promises, for example.

`let text1= string.substring(0,1500); let text2= string.substring(1500,3400);

this.textToSpeech.speak({ text: text1, locale: 'es-MX', }).then(()=>{ this.textToSpeech.speak({ text: text2, locale: 'es-MX', }).then(()=>{

}) }).catch((err)=>{ })`

checosele avatar Mar 20 '18 16:03 checosele

I realized that the problem exists in Android, but not in IOS.

checosele avatar Mar 26 '18 19:03 checosele

The above code did not work for me. Here's what did - please note on all the examples I found the syntax was incorrect as the callback need to be passed inside the speak call itself

TTS.speak ( { text: 'Hello, how are you today ?' }, function () { TTS.speak({ text: "I'm fine thanks" }); }, function (err) { alert(err); } );

malcolmswainecom avatar Jul 17 '19 19:07 malcolmswainecom