We Code your Dreams

home > Simple Text-to-Speech Android App

Simple Text-to-Speech Android App

package com.example.basic;
import java.util.Locale;
import android.os.Bundle;
import android.app.Activity;
import android.speech.tts.TextToSpeech;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
	EditText e;
	Button b;
	String nam;
	TextToSpeech ttobj;

	protected void onCreate(Bundle s) {
	e = (EditText)findViewById
    b = (Button)findViewById(R.id.button1);

        /* Creating Object of textToSpeech*/
        ttobj=new TextToSpeech
(getApplicationContext(), 			      new TextToSpeech.OnInitListener() 
	public void onInit(int status) 
        if(status != TextToSpeech.ERROR)


        /*Button Listener*/
        b.setOnClickListener(new View.OnClickListener()
     public void onClick(View v)
       	 nam = e.getText().toString();	
    	 speakText(); //call to method SpeechToText()

        }); //onClickListener
    		}//onCreate Bundle

	 public void speakText(){
nam, Toast.LENGTH_SHORT).show();
TextToSpeech.QUEUE_FLUSH, null);


Label - android

by - Chinmay Mahajan

Are you looking for something else?

Suggested Programs

Working with SQlite Database in Android

How to check values inserted in SqliteDatabase

How to retrieve values from SQlite Database

Simple Android program to insert values into Database

Error while Creating New Android Project in Eclipse