Note that there are some explanatory texts on larger screens.

plurals
  1. POText To Speech app UI is slow android
    primarykey
    data
    text
    <p>In my app I am using TTS. I have 20 different activities which are changed when the user swipe left or right. According the activity, a text is spoken. I am executing tts with separate thread and activity selection is done with main thread. But the problem is very slow, the UI feels slugish. When I swipe left or right, once tts is finished speaking the text, the activity changes which shouldn't happen because I am using separate thread for tts. Here is the codE:</p> <p><em>TTS class:</em></p> <pre><code>public class textToSpeech { TextToSpeech tts=null; public textToSpeech(Context con) { tts = new TextToSpeech(con,new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if(status != TextToSpeech.ERROR) // initialization me error to nae ha { tts.setPitch(1.1f); // saw from internet tts.setSpeechRate(0.4f); // f denotes float, it actually type casts 0.5 to float tts.setLanguage(Locale.US); } } }); } public void SpeakText (String text) { tts.speak(text, TextToSpeech.QUEUE_FLUSH, null); // TextToSpeech.QUEUE_FLUSH forces the app to stop all the sounds that are currently playing before speaking this text } public void stopSpeak() { tts.stop(); } </code></pre> <p><em>Gesture Reader Class: (separate class)</em></p> <pre><code>public void decideAlphabet() { tts.stopSpeak(); threadForTTS.start(); switch (i) { case 0: activities=null; activities = new Intent(contxt,A.class); contxt.startActivity(activities); break; case 1: activities=null; activities = new Intent(contxt,B.class); contxt.startActivity(activities); break; ....... 20 more case statements for selecting activities } </code></pre> <p>decideActivity() method is called when it is checked, which swipe was made, swipe to right or left. </p> <p>NOTE:</p> <p>Before adding tts in this app, the UI was performing properly without lag or slowness. After I added TTS, the app became slow. How can I solve this problem</p> <p>Regards</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload