Android¤Ç¥Þ¥ë¥Á¥ê¥ó¥¬¥ëTTS(²»À¼¹çÀ®)¥¢¥×¥ê

¥«¥Æ¥´¥ê
¥Ö¥Ã¥¯¥Þ¡¼¥¯¿ô
¤³¤Î¥¨¥ó¥È¥ê¡¼¤ò´Þ¤à¤Ï¤Æ¤Ê¥Ö¥Ã¥¯¥Þ¡¼¥¯ ¤Ï¤Æ¤Ê¥Ö¥Ã¥¯¥Þ¡¼¥¯ - Android¤Ç¥Þ¥ë¥Á¥ê¥ó¥¬¥ëTTS(²»À¼¹çÀ®)¥¢¥×¥ê
¤³¤Î¥¨¥ó¥È¥ê¡¼¤ò¤Ï¤Æ¤Ê¥Ö¥Ã¥¯¥Þ¡¼¥¯¤ËÄɲÃ
¤Ï¤¸¤á¤Þ¤·¤Æ¤³¤ó¤Ë¤Á¤Ï
9·î¤ËÆþ¼Ò¤·¤Þ¤·¤¿¡¢Android¥¢¥×¥ê³«È¯¼Ô¤Î¤¿¤«¤Ê¤Ç¤¹¡£

º£Æü¤ÏAndroid¤ÎÅëºÜµ¡Ç½¤Ç¤¢¤ë¡ÖTTS¡Ê²»À¼¹çÀ®¡Ë¡×¤òÍѤ¤¤¿ ¥Þ¥ë¥Á¥ê¥ó¥¬¥ëTTS¥¢¥×¥ê¤òºî¤Ã¤Æ¤ß¤¿¤¤¤È»×¤¤¤Þ¤¹!

20111228-171243



TTS¤È¤Ï


TTS¤Ï Text To Speech ¤Îά¤Ç¤¹¡£Æɤó¤Ç»ú¤Î¤´¤È¤¯¡¢²»À¼¹çÀ®¤ò»Ø¤·¤Þ¤¹¡£

½é²»¥ß¥¯¤Ê¤É¤ÎVocaloid¡¢±Ø¤Î¥¢¥Ê¥¦¥ó¥¹¡¢¥í¥Ü¥Ã¥È¤ËÅëºÜ¤µ¤ì¤Æ¤¤¤ë²»À¼¤ò¼ª¤Ë¤·¤¿¤³¤È¤¬¤¢¤ë¿Í¤â¿¤¤¤Ç¤·¤ç¤¦¡£ËÀÆɤߤÁ¤ã¤ó¤ò»È¤Ã¤Æ¤¤¤ë¿Í¤â¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¤Í¡£

TTS¤Ï¡ÖưŪ¤ËÊѲ½¤¹¤ë¾ðÊó¤ò¥ê¥¢¥ë¥¿¥¤¥à¤Ë¤·¤ã¤Ù¤Ã¤Æ¤Û¤·¤¤¡×¡Ö¾õ¶·¤Ë±þ¤¸¤ÆÁÇÁ᤯¥¢¥Ê¥¦¥ó¥¹¤·¤¿¤¤¡×¡Ö¤¤¤Ä¤Ç¤â¡¢¤É¤³¤Ç¤â¡¢¼ê´Ö¤ò¤«¤±¤º¤Ë¾ðÊó¤òȯ¿®¤·¤¿¤¤¡×¤È¤¤¤Ã¤¿¥Ë¡¼¥º¤ËÂбþ¤¹¤ë¤è¤¦ºî¤é¤ì¡¢Í¹Êضɤäɱ¡¤ÎÈֹ滥¤ÎÆɤ߾夲¤Ê¤É¤«¤é¡¢¶áǯ¤Ç¤ÏÆùÀ¼¤Ë¶á¤¤¤Ê¤á¤é¤«¤Êȯ²»¤Î¥â¥Ç¥ë¤âÁý¤¨¤Æ¤­¤Þ¤·¤¿¡£


Android¤ËTTS¤¬É¸½àÅëºÜ


Android 1.6¤«¤é¡¢TTSµ¡Ç½¤¬É¸½àÅëºÜ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤¿¤À¤·¡¢²»À¼¤ò¹çÀ®¤¹¤ë¤¿¤á¤Ë¤Ï¥Ü¥¤¥¹¥Ç¡¼¥¿¤È¸Æ¤Ð¤ì¤ë²»À¼¤Î¥Ñ¡¼¥Ä¤Î½¸¹ç¡Ê¥¢¥×¥ê·Á¼°¡Ë¤ò¥¤¥ó¥¹¥È¡¼¥ë¤¹¤ëɬÍפ¬¤¢¤ê¡¢¤½¤Î¤Þ¤Þ¤Ç¤Ï»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£

º£²ó¤Î¥¢¥×¥ê¤Ç¤Ï¤½¤ÎÅÀ¤ò²ÃÌ£¤·¤Æ¡¢¥Ü¥¤¥¹¥Ç¡¼¥¿¤Î̵ͭ¤ò¥Á¥§¥Ã¥¯¡¢¤Ê¤±¤ì¤Ð¥Þ¡¼¥±¥Ã¥È¤Î³ºÅö¥¢¥×¥ê¤ØÁ«°Ü¤¹¤ë¡¢¤È¤¤¤¦µ¡Ç½¤âÉղ䷤Ƥ¤¤Þ¤¹¡£


AndroidTTS¤ÎÂбþ¸À¸ì


¸½ºß¡¢AndroidTTS¤ÎÂбþ¸À¸ì¤Ï¡Ö±Ñ¸ì¡Ê¥¤¥®¥ê¥¹±Ñ¸ì¤ò´Þ¤à¡Ë¡×¡Ö¥Õ¥é¥ó¥¹¸ì¡×¡Ö¥É¥¤¥Ä¸ì¡×¡Ö¥¤¥¿¥ê¥¢¸ì¡×¡Ö¥¹¥Ú¥¤¥ó¸ì¡×¤Î5¤Ä¤Ç¤¹¡£ ¼«Ê¬¤ÎAndroidüËö¤¬¤É¤Î¸À¸ì¤ò¤·¤ã¤Ù¤ì¤ë¤«¤Ï¡¢¡ÖÀßÄê¡×¢ª¡Ö²»À¼Æþ½ÐÎϡעª¡Ö¥Æ¥­¥¹¥ÈÆɤ߾夲¤ÎÀßÄê¡×¢ª¡Ö¸À¸ì¡×¤Ç³Îǧ¤Ç¤­¤Þ¤¹¡£

»ÄÇ°¤Ê¤¬¤éÆüËܸìÈóÂбþ¤È¤Î¤³¤È¤Ç¡¢ÆüËܸì¤Î¹çÀ®¤ò¼Â¸½¤¹¤ë¤¿¤á¤Ë¤ÏÊ̤Υ饤¥Ö¥é¥ê¤¬É¬ÍפǤ¹¡£


AndroidTTS¤ò»È¤Ã¤Æ¤ß¤ë


SDK¤Î¡ÖTextToSpeech¡×¥¯¥é¥¹¤ò»È¤¤¤Þ¤¹¡£
¥ê¥Õ¥¡¥ì¥ó¥¹¤Ï¤³¤Á¤é¡¡TextToSpeech - Android Developers

¤·¤ã¤Ù¤é¤»¤ë¤³¤È¼«ÂΤϤȤƤâ´Êñ¤Ç¡¢ speak¥á¥½¥Ã¥É¤Î°ú¿ô¤ËÆɤó¤Ç¤Û¤·¤¤¥Æ¥­¥¹¥È¤òÍ¿¤¨¤ë¤À¤±¤Ç¤¹¡£
³Æ¸À¸ì¤ÎÀßÄê¤ò¹Ô¤¦¤Ë¤ÏsetLanguage¥á¥½¥Ã¥É¤ÇLocale¤ò»ØÄꤷ¤Þ¤¹¡£
º£¤ÎÀßÄ꤬¤É¤Î¸À¸ì¤«?¤òÄ´¤Ù¤ë¤¿¤á¤Ë¤ÏgetLanguage()¤·¤Þ¤·¤ç¤¦¡£

¤Þ¤¿¡¢¼«Ê¬°Ê³°¤Î¿Í¤ÎüËö¤Ç¥¢¥×¥ê¤ò»È¤Ã¤ÆÍߤ·¤¤¾ì¹ç¤Ï¡¢¤½¤ÎüËö¤ÎÂбþ¸À¸ì¤òÄ´¤Ù¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¤³¤ì¤ÏisLanguageAvailable¥á¥½¥Ã¥É¤ËLocale¤ò»ØÄꤹ¤ë¤³¤È¤Ç¡¢¥¹¥Æ¡¼¥¿¥¹¤¬TextToSpeech¤ÎÄê¿ô¤È¤·¤ÆÊ֤äƤ­¤Þ¤¹¡£

Îã¡ËüËö¤¬¥¢¥á¥ê¥«±Ñ¸ì¤ÎTTS¤ËÂбþ²Äǽ¤«¤òȽÃǤ¹¤ë¤¿¤á¤Ë¤Ï
if (mtts.isLanguageAvailable(Locale.US) >= TextToSpeech.LANG_AVAILABLE) {
¡¡¡¡¡¡//Âбþ²Äǽ¤À¤Ã¤¿»þ¤Î½èÍý
}

¤È¤Ê¤ê¤Þ¤¹¡£ TextToSpeech.LANG_AVAILABLE¤Ï¡Ö¸À¸ì¤¬»ÈÍѲÄǽ¤Ç¤¢¤ë¡×¤³¤È¤ò»Ø¤·¤Æ¤¤¤Æ¡¢ ¥¹¥Æ¡¼¥¿¥¹¤¬LANG_AVAILABLE°Ê¾å¤Î¾õÂ֤Ǥ¢¤ì¤Ð¹çÀ®¤¬²Äǽ¤Ç¤¹¡£

;Ã̤Ǥ¹¤¬¡¢¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤Locale¤Ê¤éLANG_NOT_SUPPORTED¡¢É¬Íפʥܥ¤¥¹¥Ç¡¼¥¿¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤Ê¤¤¤ÈLANG_MISSING_DATA¤¬Ê֤äƤ¯¤ë¤Î¤Ç¡¢É¬Íפ˱þ¤¸¤Æ½èÍý¤ò²Ã¤¨¤Þ¤·¤ç¤¦¡£


ºî¤Ã¤Æ¤ß¤è¤¦


¥¢¥×¥ê¤Î»ÅÍͤǤ¹¡£

  1. ¤Ï¤¸¤á¤Ë¥Ü¥¤¥¹¥Ç¡¼¥¿¤¬¤¢¤ë¤«¤É¤¦¤«¥Á¥§¥Ã¥¯¤¹¤ë

  2. ¥Ø¥ë¥×¥Ü¥¿¥ó¤ò²¡¤¹¤È¥¬¥¤¥É²»À¼¤¬Î®¤ì¤ë

  3. ¥Ç¥Õ¥©¥ë¥È¤Ï¥¢¥á¥ê¥«±Ñ¸ì

  4. ¥Æ¥­¥¹¥È¤òÆþÎϤ·¤Æ¡ÖTextToSpeech!¡×¥Ü¥¿¥ó¤ò²¡¤¹¤È¹çÀ®¤·ºÆÀ¸

  5. ¡ÖLaguage¡×¥Ü¥¿¥ó¤Ç¸À¸ì¤ÎÀÚ¤êÂؤ¨¤¬²Äǽ



¥µ¥ó¥×¥ë¥³¡¼¥É


TextToSpeechActivity.java

package jp.android;

import java.util.Locale;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class TextToSpeechActivity extends Activity  implements TextToSpeech.OnInitListener {

    private static final int CHECK_TTS = 682730935;
    private Button mSpeakButton;
    private TextToSpeech mTts;
    private EditText et;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        this.checkTTS();

        mTts = new TextToSpeech(this, this);

        this.mSpeakButton =
            (Button) findViewById(R.id.speak_button);
        et = (EditText)findViewById(R.id.inputText);
        mSpeakButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                startTTS(et.getText().toString());
            }
        });

    }

    /**
     * TTS¥¨¥ó¥¸¥ó¤¬¥¤¥ó¥¹¥È¡¼¥ëºÑ¤«¤É¤¦¤«¤òȽÄê
     */
    private void checkTTS() {
        Intent intent = new Intent();
        intent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
        startActivityForResult(intent, CHECK_TTS);        
    }

    // ¥Á¥§¥Ã¥¯¤Î·ë²Ì¤ò¼õ¤±¼è¤ë
    protected void onActivityResult(int requestCode, int resultCode,
            Intent data) {
        if (requestCode == CHECK_TTS) {
            if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
                //¥¤¥ó¥¹¥È¡¼¥ëºÑ¤Ê¤é¥¦¥§¥ë¥«¥à¥á¥Ã¥»¡¼¥¸¤òȯÏÃ
                startTTS("Welcome to TTS application, Let`s start!");
            }
            else {
                //¥¤¥ó¥¹¥È¡¼¥ë̵¤·¤Ê¤é
                Intent install = new Intent();
                install.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                startActivity(install);
            }
        }
    }

    /**
     * ¹çÀ®¤ò¼Â¹Ô
     * @param text Æɤ߾夲¤¿¤¤¥Æ¥­¥¹¥È
     */
    private void startTTS(String text) {
        mTts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
    }

    /**
     * ¥Ø¥ë¥×¥¬¥¤¥É¤òÆɤ߾夲¤ë
     * @param v
     */
    public void startGuide(View v) {
        mTts.setLanguage(Locale.US);
        startTTS(getString(R.string.guide));
    }

    /**
     * ¸À¸ìÁªÂò¥Ü¥¿¥ó
     * @param v
     */
    public void onSelectLang(View v) {
        AlertDialog.Builder ab = new AlertDialog.Builder(this);
        String[] str = {"English","French","German","Italian","United Kingdom"};
        ab.setItems(str, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int i) {
                switch (i){
                    case 0:
                        mTts.setLanguage(Locale.US);
                        break;
                    case 1:
                        mTts.setLanguage(Locale.FRENCH);
                        break;
                    case 2:
                        mTts.setLanguage(Locale.GERMAN);
                        break;
                    case 3:
                        mTts.setLanguage(Locale.ITALIAN);
                        break;
                    case 4:
                        mTts.setLanguage(Locale.UK);
                            break;
                }
                
            }
        });
        ab.show();
    }

    public void onInit(int status) {        
        if (status == TextToSpeech.SUCCESS) {
            if (mTts.isLanguageAvailable(Locale.US) >= 
                    TextToSpeech.LANG_AVAILABLE) {
                //¥¢¥á¥ê¥«±Ñ¸ì¤ËÀßÄê
                mTts.setLanguage(Locale.US);
            }
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        mTts.shutdown();
    }
}



20111228-171254

Èó¾ï¤Ë´Êñ¤Ë¥Þ¥ë¥Á¥ê¥ó¥¬¥ë¤ÊTTS¥¢¥×¥ê¤¬ºî¤ì¤Þ¤·¤¿¡£


Ãí°ÕÅÀ


speak¥á¥½¥Ã¥É¤ÏÈóƱ´ü¤Ê¤Î¤Ç¡¢²»À¼¤Î¹çÀ®½èÍý¡¦ºÆÀ¸Ãæ¤Ï¥¿¥¹¥¯¤Î¾õÂ֤˱þ¤¸¤¿½èÍý¤¬É¬ÍפǤ¹¡£ÆäËŤ¤Ê¸¾Ï¤òÆɤޤ»¤¿¤¤¾ì¹ç¡ÊÆþÎϤµ¤ì¤ëʸ»ú¿ô¤òÀ©¸Â¤·¤Ê¤¤¾ì¹ç¡Ë¤ÏÃí°Õ¤·¤Þ¤·¤ç¤¦¡£


¥µ¥ó¥×¥ë¥×¥í¥¸¥§¥¯¥È¤Î¥½¡¼¥¹


¥¹¥Ú¡¼¥¹¤Î´Ø·¸¤ÇÁ´Éô¤Î¥½¡¼¥¹¤ÏºÜ¤»¤é¤ì¤Ê¤¤¤Î¤Ç¡¢¤³¤Á¤é¤ËÃÖ¤¤¤Æ¤ª¤­¤Þ¤¹¡£
https://www.assembla.com/code/texttospeech/git/nodes


¤Þ¤È¤á


AndroidTTS¤ò»È¤¦¤È¡¢¼ê·Ú¤Ë²»ÆÉ¥¢¥×¥ê¤¬ºî¤ì¤Þ¤¹¡£
¹çÀ®¤«¤é²»À¼ºÆÀ¸¤Þ¤Ç¤Î¥ì¥¹¥Ý¥ó¥¹¤¬Â®¤¤¤Î¤Ç¡¢¤Á¤ç¤Ã¤È¤·¤¿³°¹ñ¸ì¤Î¥È¥ì¡¼¥Ë¥ó¥°¤Ë»È¤¨¤½¤¦¤Ç¤¹¤Í¡£
Ä귿ʸ¤ò¤¢¤é¤«¤¸¤áÆþÎϤ·¤Æ¤ª¤±¤Ð¡¢³¤³°Î¹¹Ô¤Ë¤âÌòΩ¤Á¤½¤¦¤Ç¤¹¡£

¤Þ¤¿¡¢º£Ç¯1·î¤«¤é¡¢Á´¤Æ¤ÎAndroidüËö¤Ç¡¡²»À¼ÂÐÏ÷¿¥³¥ó¥·¥§¥ë¥¸¥å¥µ¡¼¥Ó¥¹netpeople : a¤¬ÍøÍѲÄǽ¤Ë¤Ê¤ë¤È¤Î¤³¤È¤Ê¤Î¤Ç¡¢TTS¤¬ÆüËܸ쥵¥Ý¡¼¥È¤µ¤ì¤¿¤éüËöƱ»Î¤Î²ñÏ䬼¸½¤¹¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£


¡ã¤ª¤Þ¤±¡äAndroid¤Ç»È¤¨¤ëÆüËܸìTTS¥é¥¤¥Ö¥é¥ê


ÆüËܸì¤Ç²»À¼¹çÀ®¤·¤Æ¤ß¤¿¤¤!¤È¤¤¤¦Êý¸þ¤±¤Ë¸ø³«¤µ¤ì¤Æ¤¤¤ë¥é¥¤¥Ö¥é¥ê¤Ç¤¹¡£
Í­ÎÁ¤Î¤â¤Î¤¬¤Û¤È¤ó¤É¤Ê¤Î¤Ç¡¢µ¤·Ú¤Ë»î¤»¤Ê¤¤¤Î¤¬¾¯¤·»ÄÇ°¤Ç¤¹¤Í¡£

²»À¼¹çÀ®¥¨¥ó¥¸¥ó "Galatea Talk"¤òÍѤ¤¤¿¥é¥¤¥Ö¥é¥ê
¥ì¥¹¥Ý¥ó¥¹
¥³¥á¥ó¥È(8)
¥È¥é¥Ã¥¯¥Ð¥Ã¥¯(0)

¤³¤Î¥¨¥ó¥È¥ê¡¼¤ò¤Ï¤Æ¤Ê¥Ö¥Ã¥¯¥Þ¡¼¥¯¤ËÄɲÃ