I'm building a text to speech application with multiple views. The application has multiple views and each view has 2 buttons.
So, when a user presses a button, the engine speaks the contents of button (speaks what's written on the button).
I have created a separate class currently which holds the function that does the job of speaking. I pass the text that has to be spoken to this function. This is working just fine.
But, let's say the the text on button 1 is big and when the engine is speaking, the user presses the button 2 (on same page), the engine will first finish the button 1 text and then speak text of button 2. This is clearly not good.
So, I was thinking of initiating a background thread that will listen to events. This background thread will keep running and needs a string to be passes to it, which can be then passes to the function I made for text to speech. This will change the contents of the function in real time and the engine will speak when the user presses the button.
Any suggestions on how to make this background thread? or some other suggestion for this?