i was wondering how to code a text box in the source code so when you start the program you can type in the word and it will say it instead of having to go into the source code and change it. this is what i have so far
package edu.lms.whezthah;
import java.util.Locale;
import android.app.Activity; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.util.Log; import android.widget.Button; import android.widget.EditText;
public class WhezthahActivity extends Activity implements TextToSpeech.OnInitListener { ////////////// // FIELDS private static final String TTS_TAG = "TextToSpeech"; public EditText edittext; public Button button; public TextToSpeech mTts; public boolean mFlagTtsAvailable; public boolean mInitButtonFocus; public boolean mInitEditTextFocus; ////////////// // METHODS
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
// Initialize text-to-speech. This is an asynchronous operation.
// The OnInitListener (second argument) is called after initialization completes.
mTts = new TextToSpeech(this,
this // TextToSpeech.OnInitListener
);
}
@Override
public void onDestroy() {
// Shutdown speech synthesizer.
if (mTts != null) {
mTts.stop();
mTts.shutdown();
}
super.onDestroy();
}
/**
* Implement TextToSpeech.OnInitListener.
* @param status
*/
@Override public void onInit(int status) { mFlagTtsAvailable = false;
// status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR.
if (status == TextToSpeech.SUCCESS) {
// Set preferred language to US English.
// Note that a language may not be available, and the result will indicate this.
int result = mTts.setLanguage(Locale.US);
mTts.isLanguageAvailable(Locale.GERMAN);
mTts.isLanguageAvailable(Locale.FRENCH);
// Try this someday for some interesting results.
// int result = mTts.setLanguage(Locale.FRANCE);
if (result == TextToSpeech.LANG_MISSING_DATA ||
result == TextToSpeech.LANG_NOT_SUPPORTED) {
// Language data is missing or the language is not supported.
Log.e(TTS_TAG, "Language is not available.");
}
else {
// Check the documentation for other possible result codes.
// For example, the language may be available for the locale,
// but not for the specified country and variant.
String text = "type in the box to trranslate";
mTts.speak(text, TextToSpeech.QUEUE_ADD, null);
//text = "<speak xml:lang=\"en-US\"> <phoneme alphabet=\"xsampa\" ph=\"no_Uz nO_Iz r\\\\a_Iz r\\\\a_Uz r\\\\e_Iz\"/>.</speak>";
//mTts.speak(text, TextToSpeech.QUEUE_ADD, null);
mFlagTtsAvailable = true;
}
} else {
// Initialization failed.
Log.e(TTS_TAG, "Could not initialize TextToSpeech.");
}
}
}