Used code:
public class TexttoSpeechActivity extends Activity implements OnInitListener { private TextToSpeech tts; private Button btnSpeak; private EditText txtText; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tts = new TextToSpeech(this, this); btnSpeak = (Button) findViewById(R.id.btnSpeak); txtText = (EditText) findViewById(R.id.txtText); btnSpeak.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { speakOut(); } }); } @Override public void onDestroy() {
success status is returned from onInit (). But there are some delays for the first performance. those. if you immediately click on the start button to speak, tts does not work. After some delay (10-15 seconds) it works fine.
I can use a handler to wait 10-15 seconds, as described in Text to Speech does not work as expected . But this is not good. Since this delay of 10-15 seconds can vary from device to device. Does anyone know how to handle this first delay.
source share