Text to speech in android

Text to speech converter android

Follow the simple step to create this application.

Here, is the coding for converter the text into the speech. Its very useful to read stores by the mobile itself and etc.

1. A TextToSpeech instance can only be used to synthesize text once it has completed its initialization. Implement the TextToSpeech.OnInitListener to be notified of the completion of the initialization.

public void onInit(int status) {

if (status == TextToSpeech.SUCCESS) {
Toast.makeText(TtsActivity.this, "Text-To-Speech engine is initialized", Toast.LENGTH_LONG).show();
else if (status == TextToSpeech.ERROR) {
Toast.makeText(TtsActivity.this, "Error occurred while initializing Text-To-Speech engine", Toast.LENGTH_LONG).show();

2. Check whether the TextToSpeech Engine available in the current device by startActivityForResult intent.

Intent checkIntent = new Intent();
startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);

3. If the TextToSpeech engine in available creates the TextToSpeech instance.
TexttoSpeech tts;
tts=new TexttoSpeech(this,this);

4. If TexttoSpeech engine not available install it,

TexttoSpeech tts;
tts=new TexttoSpeech(this,this);
Intent installIntent = new Intent();

5. Finally, Enter the text into the edittext field, Then click the button to perform the speech action, after click button using tts.speak(); the method of speech the text.



Leave a Reply

Your email address will not be published. Required fields are marked *