Guest User

Untitled

a guest
Jan 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public class MainActivity extends Activity implements RecognitionListener
  2.  
  3. SpeechRecognizer speech = SpeechRecognizer.createSpeechRecognizer(this);
  4. speech.setRecognitionListener(this);
  5. intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  6. intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
  7. RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
  8. intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
  9. intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, this.getPackageName());
  10. speech.startListening(intent);
  11.  
  12. ArrayList<String> result = data.getStringArrayListExtra(
  13. RecognizerIntent.EXTRA_RESULTS);
  14. textview.setText(result.get(0));
  15.  
  16. @Override
  17. public void onBeginningOfSpeech() {
  18.  
  19. }
  20.  
  21. @Override
  22. public void onRmsChanged(float rmsdB) {
  23.  
  24. }
  25.  
  26. @Override
  27. public void onBufferReceived(byte[] buffer) {
  28.  
  29. }
  30.  
  31. @Override
  32. public void onEndOfSpeech() {
  33.  
  34. }
  35.  
  36. @Override
  37. public void onError(int error) {
  38.  
  39. }
  40. @Override
  41. public void onReadyForSpeech(Bundle params) {
  42.  
  43. }
Add Comment
Please, Sign In to add comment