Reputation: 437
I have implemented Text to speech functionality in my ionic2
code.
I am not able to stop the current tts in iPhone device.
I have used following code :
this.tts.speak("").then((value) => { console.log('tts stopped !!! '); });
The above code has stopped the current tts in android but can't able to stop in iPhone.
I have also used
tts.stop()
method for stop current speech, but still not stopped.
Source : Text to speech
This is only not working in iPhone.
Please suggest for any solution.
Thanks in advance.
Upvotes: 1
Views: 227
Reputation: 24234
To stop any current TTS playback you can follow this example:
this.tts.speak("").then( _=> {
this.tts.stop();
console.log('tts stopped !!! ');
});
If you want to stop it in any time, just create a function to do that:
<button ion-button (click)="stopTTS()">Stop TTS</button>
In TS:
stopTTS() {
if (!!this.tts) this.tts.stop();
}
Upvotes: 1