2

I am working on a vocabulary app where there would be TTS in most of the activities. I am implementing TTS as illustrated in http://www.androidhive.info/2012/01/android-text-to-speech-tutorial/

However, I discover and is quite certain that setting TTS in OnCreate causing the app opening the Activity with TTS terribly slow. (tested by running same activity with and without TTS)

// setup TTS part 1.1
mTts = new TextToSpeech(ActivityA.this, this);  // TextToSpeech.OnInitListener

Question:

How can the process be faster? Loading the TTS at background? Yet once opened the layout of ActivityA, it must need to immediately speak / pronounce the vocabulary.

pearmak
  • 4,979
  • 15
  • 64
  • 122

1 Answers1

0

This month (May 2014) Google released an updated version of the Google TTS engine (v3.1.3). With the new version my experience has been it can take up to 5 seconds to init the engine which makes pearmak's question even more pertinent.

My solution to this problem is to preload google tts by having the parent activity create an instance of the TTS engine and hold on to the instance. When the user navigates to a new activity that requires TTS that activity still creates its own instance of the TTS, but the init time is now milliseconds. There is very little delay in opening the activity and being ready to speak.

The drawback to this is the Google TTS process is running (consuming memory) when it may not be needed. This also may be difficult to manage if your UI does not have a hierarchical design.

rgretzi
  • 1
  • 4