cordova-plugin-tts
cordova-plugin-tts copied to clipboard
TTS is not working with long string 5000 characters
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.
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)=>{ })`
I realized that the problem exists in Android, but not in IOS.
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); } );