 |
|
In this article I will show the most simple way to add text to speech abilities to your Android application. |
public class Text2SpeechTest extends Activity implements OnInitListener {
TextToSpeech talker;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
talker = new TextToSpeech(this, this);
}
public void say(String text2say){
talker.speak(text2say, TextToSpeech.QUEUE_FLUSH, null);
}
@Override
public void onInit(int status) {
say("Hello World");
}
@Override
public void onDestroy() {
if (talker != null) {
talker.stop();
talker.shutdown();
}
super.onDestroy();
}
}
Download code example
Here is a nice example given by android itself: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/TextToSpeechActivity.html
Its good example
Muy bueno. Funciona en el emulador y en mi tableta.
Muchas gracias.
Very good. It works in the emulator and on my tablet.
Thank you very much.
Cool Man!! Thanks a lot, Even this
http://www.compiletimeerror.com/2013/08/text-to-speech-in-android.html might help you out, have a look..
Hey..It really works,But it does not works on Nexus 4,Samsung Galaxy Y
anyone knows how to add a language?, such as Spanish
——————-
Alguien sabe como añadir un idioma que no esta soportado de serie, como por ejemplo Español.
Gracias. un saludo.
Can anyone tell that how to use google to speech tts and espeak app both in my application. i want to use both, randomly.