Text to Speech Example in Android
TEXTTOSPEECH:
this code text to speech simple example code
SOURCE CODE
public class MainActivity extends Activity implements OnInitListener {
TextToSpeech textTalker;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button tv=(Button)findViewById(R.id.button1);
textTalker = new TextToSpeech(this, this);
tv.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
EditText et=(EditText)findViewById(R.id.editText1);
textTalker.speak(et.getText().toString(), TextToSpeech.SUCCESS, null);//if it not work with this use below commented line
this code text to speech simple example code
SOURCE CODE
public class MainActivity extends Activity implements OnInitListener {
TextToSpeech textTalker;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button tv=(Button)findViewById(R.id.button1);
textTalker = new TextToSpeech(this, this);
tv.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
EditText et=(EditText)findViewById(R.id.editText1);
textTalker.speak(et.getText().toString(), TextToSpeech.SUCCESS, null);//if it not work with this use below commented line
//textTalker.speak(intentDataHolder.getString("MsgTxt"), TextToSpeech.QUEUE_ADD, null);
}
});
}
@Override
public void onDestroy() {
if (textTalker != null) {
textTalker.stop();
textTalker.shutdown();
}
super.onDestroy();
}
public void onInit(int status) {
// TODO Auto-generated method stub
}
}
}
});
}
@Override
public void onDestroy() {
if (textTalker != null) {
textTalker.stop();
textTalker.shutdown();
}
super.onDestroy();
}
public void onInit(int status) {
// TODO Auto-generated method stub
}
}
Cool Maddy!! Thanks a lot, Even this http://www.compiletimeerror.com/2013/08/text-to-speech-in-android.html might help you out, have a look..
ReplyDelete