Androidの音声認識とテキスト読み上げ機能について

16,649 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
16,649
On SlideShare
0
From Embeds
0
Number of Embeds
354
Actions
Shares
0
Downloads
33
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Androidの音声認識とテキスト読み上げ機能について

  1. 1. Android
  2. 2. Android iPhone Android iPhone API Android
  3. 3. Google API ( ) Android API
  4. 4. Google API (TTS:Text-To-Speech Android API
  5. 5. Android → → →
  6. 6. http://nd-ilab.jp/android/android_pinyin_translate.apk
  7. 7. twitter
  8. 8. Activity Activity
  9. 9. → →Droid Jammer droid → →Twitroid Twitter →
  10. 10. Intent RecognizerIntent.ACTION_RECOGNIZE_SPEECH android.speech.action.RECOGNIZE_SPEECH Intent
  11. 11. Intent // recognitionButton.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { try { Intent intent = new Intent( RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra( RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra( RecognizerIntent.EXTRA_PROMPT, getText(R.string.dialog_recognition)); startActivityForResult(intent, REQUEST_CODE); } catch (ActivityNotFoundException e) { } } });
  12. 12. Intent // recognitionButton.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { try { Intent intent = new Intent( RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra( RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra( RecognizerIntent.EXTRA_PROMPT, getText(R.string.dialog_recognition)); LANGUAGE_MODEL_WEB_SEARCH startActivityForResult(intent, REQUEST_CODE); Web } catch (ActivityNotFoundException e) { } LANGUAGE_MODEL_FREE_FORM } });
  13. 13. protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) { String resultsString = ""; // ArrayList<String> results = data.getStringArrayListExtra( RecognizerIntent.EXTRA_RESULTS); for (int i = 0; i< results.size(); i++) { resultsString += results.get(i); } this.searchText.setText(resultsString); } super.onActivityResult(requestCode, resultCode, data); }
  14. 14. • → API Google 3G Wifi →Google →Activity → → Android →
  15. 15. • → ※ RecognizerIntent.EXTRA_LANGUAGE
  16. 16. • mp3 API → • Google API → ML
  17. 17. Text-To-Speech API (android.speech.tts.TextToSpeech) android.intent.action.START_TTS_SERVICE Activity
  18. 18. TTS //TTS @Override public void onInit(int status) { if(status == TextToSpeech.SUCCESS){ if(tts.isLanguageAvailable(Locale.US) == TextToSpeech.LANG_MISSING_DATA){ new AlertDialog.Builder(this).setTitle("warning").setMessage("tts(us) not supprted").show(); }else{ tts.setLanguage(Locale.US); tts.setPitch(1.8f); tts.setSpeechRate(0.8f); } }else{ new AlertDialog.Builder(this).setTitle("error").setMessage("tts#onInit error").show(); finish(); } }
  19. 19. TTS //TTS @Override public void onInit(int status) { if(status == TextToSpeech.SUCCESS){ if(tts.isLanguageAvailable(Locale.US) == TextToSpeech.LANG_MISSING_DATA){ new AlertDialog.Builder(this).setTitle("warning").setMessage("tts(us) not supprted").show(); }else{ tts.setLanguage(Locale.US); tts.setPitch(1.8f); tts.setSpeechRate(0.8f); } }else{ new AlertDialog.Builder(this).setTitle("error").setMessage("tts#onInit error").show(); finish(); } }
  20. 20. SearchResult result = currentResult.get(position); if(tts.isSpeaking()){ tts.stop(); } HashMap<String, String> params = new HashMap<String, String>(); params.put(TextToSpeech.Engine.KEY_PARAM_STREAM,String.valueOf (AudioManager.STREAM_MUSIC)); tts.speak(result.getChn(), TextToSpeech.QUEUE_FLUSH, params); ※ ※ (tts.isSpeaking()
  21. 21. SearchResult result = currentResult.get(position); if(tts.isSpeaking()){ tts.stop(); } HashMap<String, String> params = new HashMap<String, String>(); params.put(TextToSpeech.Engine.KEY_PARAM_STREAM,String.valueOf (AudioManager.STREAM_MUSIC)); tts.speak(result.getChn(), TextToSpeech.QUEUE_FLUSH, params); STREAM_ALARM ※ STREAM_MUSIC ※ STREAM_NOTIFICATION (tts.isSpeaking()
  22. 22. Text-To-Speech API http://eyes-free.googlecode.com/ eSpeak TTS PICO Google TTS 20 C
  23. 23. Text-To-Speech API http://gimite.net/pukiwiki/index.php?Android%20JaTTS Android mp3 Galatea Talk http://hil.t.u-tokyo.ac.jp/~galatea/index-jp.html
  24. 24.
  25. 25. TTS Expanded Android JaTTS →Android
  26. 26. Android API Android

×