spasma / cordova-plugin-tts-advanced

11 stars 18 forks source link

waiting for stop event. #6

Open Simbaclaws opened 3 years ago

Simbaclaws commented 3 years ago

Hey,

apparently when I do:

TTS.stop().then(() => {
          this.isTalking = false;
          console.log('stopped');
        }).catch((reason: any) => {
          this.isTalking = false;
          console.log(reason);
        });

The then and catch are not being called... The stop is being called though, so I think I'lll just remove the .then and set it to false after calling stop.

It is nice to have a callback to know whether it stopped or errored out for some reason though.

blukis commented 3 years ago

Just as a workaround to this, I've been using...

TTS.speak({text: "", cancel: true }).then(
    function() { alert("success"); },
    function(msg) { alert("error: " + JSON.stringify(msg)); }
);
givethanks1 commented 3 years ago

Great plugin, works very nicely on Android.

However, I'm also seeing a similar cancel issue as the first user on iOS. When i run the following, the speaking stops. Which is great. However, it does not actually show the "successful cancel" in the log / output the console.log value until i try to perform the next TTS.speak action. At which point it executes the earlier cancel and shows 'successful cancel' in the console.log area (but: it's after the user has asked for the next piece of speech -- which leads to its cancellation). The user must press "play" twice to get it to play again after a stop/cancel.

TTS.speak({text: "", cancel: true }).then(
    function() { console.log('successful cancel'); },
    function(msg) { console.log('failure to cancel'); }
);

Any suggestions are welcome.

givethanks1 commented 3 years ago

Seems apple may be at fault here per: https://stackoverflow.com/questions/19672814/an-issue-with-avspeechsynthesizer-any-workarounds