Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends Activity implements RecognitionListener
- SpeechRecognizer speech = SpeechRecognizer.createSpeechRecognizer(this);
- speech.setRecognitionListener(this);
- intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
- intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
- RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
- intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
- intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, this.getPackageName());
- speech.startListening(intent);
- ArrayList<String> result = data.getStringArrayListExtra(
- RecognizerIntent.EXTRA_RESULTS);
- textview.setText(result.get(0));
- @Override
- public void onBeginningOfSpeech() {
- }
- @Override
- public void onRmsChanged(float rmsdB) {
- }
- @Override
- public void onBufferReceived(byte[] buffer) {
- }
- @Override
- public void onEndOfSpeech() {
- }
- @Override
- public void onError(int error) {
- }
- @Override
- public void onReadyForSpeech(Bundle params) {
- }
Add Comment
Please, Sign In to add comment