Android Text to Speech is the speech the text which ever you want.
below is the code for Text to speech.
public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener{TextToSpeech textToSpeech;@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);textToSpeech = new TextToSpeech(mcontext, MainActivity.this);TextToSpeechFunction();}public void TextToSpeechFunction() { String textholder = "Test the TextToSpeech";textToSpeech.speak(textholder, TextToSpeech.QUEUE_FLUSH, null); // Toast.makeText(MainActivity.this , textholder, Toast.LENGTH_LONG).show(); } @Override public void onDestroy() { textToSpeech.shutdown(); super.onDestroy(); } public void onInit(int Text2SpeechCurrentStatus) { if (Text2SpeechCurrentStatus == TextToSpeech.SUCCESS) { textToSpeech.setLanguage(Locale.US); TextToSpeechFunction(); } }}
No comments:
Post a Comment
Comments