I am using Google TTS Engine for Text-to-speech for Hindi Language.

 In onCreate Methode i have created an Intent to check whether voice data 
installed, and it gives result to onActivityResult methode

@Overrideprotected void onActivityResult(int requestCode, int resultCode, 
Intent data) {
    switch (requestCode) {
    case ACTIVITY_TTS_PASS:
        if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
            tts = new TextToSpeech(getApplicationContext(), this);
            int availability = tts.isLanguageAvailable(new Locale("hin-IND"));
            switch(availability) {
            case TextToSpeech.LANG_AVAILABLE:
                Log.d("TTS", "Language available");
                break;
            case TextToSpeech.LANG_NOT_SUPPORTED:
                Log.d("TTS", "Language not supported");

                Intent installTTSIntent = new Intent();
                
installTTSIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                ArrayList<String> languages = new ArrayList<String>();
                languages.add("hin-IND"); // hin - hindi, IND - INDIA
                installTTSIntent.putStringArrayListExtra(
                        TextToSpeech.Engine.EXTRA_CHECK_VOICE_DATA_FOR, 
languages);
                startActivity(installTTSIntent);
                break;
            case TextToSpeech.LANG_MISSING_DATA:
                Log.d("TTS", "Language missing data");
                break;
            case TextToSpeech.LANG_COUNTRY_AVAILABLE:
                Log.d("TTS", "Contry available");
                break;
            default:
                Log.d("TTS", "default");
            }
        }
        else {
            Log.d("TTS", "fail");
            Intent installTTSIntent = new Intent();
            
installTTSIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            ArrayList<String> languages = new ArrayList<String>();
            languages.add("hin-IND"); // hin - hindi, IND - INDIA
            installTTSIntent.putStringArrayListExtra(
                    TextToSpeech.Engine.EXTRA_CHECK_VOICE_DATA_FOR, languages);
            startActivity(installTTSIntent);
        }

        break;
    default:
        Log.d("TTS", "case default");
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

Initially it comes to case TextToSpeech.LANG_NOT_SUPPORTED and prompt to 
install TTS data by selecting an option among list of languages. I selected 
'Hindi(India)' and installed successfully.

Again checking tts.isLanguageAvailable(new Locale("hin-IND")) gives the same 
result (i.e. TextToSpeech.LANG_NOT_SUPPORTED).
I am using android 4.4.4

Questions:
1. How can i check whether Google TTS Engine data is installed for Hindi 
Language (check for locale "hin-IND" OR "hi-IN") ?
2. How Is there any other approach for the same ?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to