Breaking News


Tuesday, 24 December 2013

TEXT TO SPEECH APPLICATION


TEXT TO SPEECH ANDROID APPLICATION....

Here Write any word in edit text for ex. "Hello" after click button so, listen "Hello"....

                           
Text To Seepch
Demo Text To Speech 

public class TtsActivity extends Activity implements OnInitListener,
OnClickListener { // here implement two listener...

TextToSpeech t;  /Create Text to speech object for ex. t
EditText e;
Button b;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

t = new TextToSpeech(this, this); // Text to Speech create method
e = (EditText) findViewById(R.id.editText1);
b = (Button) findViewById(R.id.button1);
b.setOnClickListener(this);
}

public void onClick(View v) {  // Button Click Activity

speakOut();

}

public void Destroy() {
if (t != null) {
t.stop();
t.shutdown();

}

super.onDestroy();

}

public void onInit(int arg0) { // Text to Speech method

if (arg0 == TextToSpeech.SUCCESS) {

int result = t.setLanguage(Locale.US);

if (result == TextToSpeech.LANG_NOT_SUPPORTED
|| result == TextToSpeech.LANG_MISSING_DATA)

{

Toast.makeText(this, "lagnguage is not supprted", 2000).show();

} else {
b.setEnabled(true);
speakOut();

}

} else {

Toast.makeText(this, "lagnguage is initiliased", 2000).show();
}



}

public void speakOut() {
String st = e.getText().toString();  // enter ur edittext word and click button so, listen word....
t.speak(st,TextToSpeech.QUEUE_FLUSH, null);

}
Share This
Blogger
Facebook
Disqus

comments powered by Disqus

1 comment :

Subscribe
Labels
Popular Posts

Subscribe Via Email

About Us

THIS IS ANDROID AND JAVA FREE TUTORIAL AND ALL PROVIDE SOLUTION IN ANDROID AND JAVA INTERVIEW QUE AND ANS IS AVAILABLE IN MY BLOG AND ANY QUERY PLEASE CONTACT ME GO NOW CONTACT US PAGE.

Total Pageviews

© Android and Java solution All rights reserved | Designed By Fireandroids