Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. public void onClick(View v) {
  2.  
  3. InputMethodManager inputManager = (InputMethodManager) this.getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
  4.  
  5. inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
  6.  
  7. /* Voice recognition using Google Speech to Text API*/
  8. if (v.getId() == R.id.VoiceConvert) {
  9.  
  10. entertext.setText("");
  11. Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  12. intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
  13. intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.sign.language");
  14. intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.speak));
  15. intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.ENGLISH);
  16. intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
  17. startActivityForResult(intent, REQUEST_CODE);
  18.  
  19.  
  20.  
  21. }
  22. }
  23.  
  24.  
  25.  
  26. public void onCreate(Bundle savedInstanceState) {
  27.  
  28. super.onCreate(savedInstanceState);
  29. setContentView(R.layout.uioneone);
  30. searchbtn = (ImageButton) findViewById(R.id.search_txt);
  31. vsearchbtn = (ImageButton) findViewById(R.id.VoiceConvert);
  32. signbtn = (ImageButton) findViewById(R.id.SignBible);
  33. exitbtn = (ImageButton) findViewById(R.id.TouchToExit);
  34. entertext = (EditText) findViewById(R.id.entert);
  35. imagev = (ImageView) findViewById(R.id.imageView1);
  36.  
  37. imagev.setOnClickListener(this);
  38. searchbtn.setOnClickListener(this);
  39. vsearchbtn.setOnClickListener(this);
  40. signbtn.setOnClickListener(this);
  41. exitbtn.setOnClickListener(this);
  42.  
  43. initSpeechRecognizer();
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement