Hello everyone……..
In this simple example I will show you how to use Text To Speech in ANDROID. This is one of the unique features in ANDROID.
Unlike iPhone , ANDROID has a built in TTS Library which supports many languages. But iPhone doesn’t have this feature. They have to depend on third-party software for implementing this.
Now go on create a fresh project and copy this following code to it.
package com.TTS; import java.util.Locale; import android.app.Activity; import android.os.Bundle; import android.speech.tts.TextToSpeech; public class TTS extends Activity implements TextToSpeech.OnInitListener { TextToSpeech tts; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tts = new TextToSpeech(this,this); } public void onInit(int status) { Locale loc = new Locale("eng", "",""); if(tts.isLanguageAvailable(loc) >= TextToSpeech.LANG_AVAILABLE){ tts.setLanguage(loc); } tts.speak("Text to speech in ANDROID from coderzheaven, Hope you like it.", TextToSpeech.QUEUE_FLUSH, null); } @Override protected void onDestroy() { super.onDestroy(); tts.shutdown(); } }
After running this application you will hear the sound that is given as text in this line.
tts.speak(“Text to speech in ANDROID from coderzheaven, Hope you like it.”, TextToSpeech.QUEUE_FLUSH, null);
Please leave your comments if this post was useful.
Great info dude thanks for useful article. I’m waiting for more
@tabletki na odchudzanie-> thank you so much… We are working more on Android, iPhone and other related stuffs… we will update with other useful resources from these… Keep in touch… and once again thank you for your support… 🙂
its nice.
i need to display that text in emulator.can any1 help me