TextToSpeech isLanguageAvailable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextToSpeech isLanguageAvailable method.

This code example shows how to use the following methods:getFeatures, getLanguage, isLanguageAvailable, speak
        } 
        return null; 
    } 
 
    private boolean isNetworkRequiredForSynthesis() { 
        Set<String> features = mTts.getFeatures(mTts.getLanguage());
        return features.contains(TextToSpeech.Engine.KEY_FEATURE_NETWORK_SYNTHESIS) &&
                !features.contains(TextToSpeech.Engine.KEY_FEATURE_EMBEDDED_SYNTHESIS);
    } 
 
    private void onSampleTextReceived(int resultCode, Intent data) {
        String sample = getDefaultSampleString();
 
        if (resultCode == TextToSpeech.LANG_AVAILABLE && data != null) {
            if (data != null && data.getStringExtra("sampleText") != null) {
                sample = data.getStringExtra("sampleText");
            } 
            if (DBG) Log.d(TAG, "Got sample text: " + sample);
        } else { 
            if (DBG) Log.d(TAG, "Using default sample text :" + sample);

8
CodeRank
This code example shows how to use the following methods:isLanguageAvailable, setLanguage, setPitch, setSpeechRate
    } 
     
    public void onInit(int status) {
        if (status == TextToSpeech.SUCCESS) {
            Locale locale = Locale.ENGLISH;
            if (tts.isLanguageAvailable(locale) >=
                TextToSpeech.LANG_AVAILABLE) {
                tts.setLanguage(locale);
                tts.setPitch(1.5f);
                tts.setSpeechRate(1.5f);
                return; 
            } 
        } 
        Logger.d("Failed to initialize"); 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:isLanguageAvailable, setLanguage, setOnUtteranceCompletedListener, setSpeechRate, sleep
 
	@SuppressWarnings("deprecation") 
	@Override 
	public void onInit(int arg0)
	{ 
		mTts.setOnUtteranceCompletedListener(this);
 
		Locale l = Locale.getDefault();
		int result = mTts.isLanguageAvailable(l);
		if (result == TextToSpeech.LANG_AVAILABLE || result == TextToSpeech.LANG_COUNTRY_AVAILABLE
				|| result == TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE)
		{ 
 
			mTts.setLanguage(l);
		} else 
		{ 
			Toast.makeText(context, "Lang not available:" + result, Toast.LENGTH_LONG).show();
		} 
 
		mTts.setSpeechRate(0.85f);

6
CodeRank
This code example shows how to use the following methods:isLanguageAvailable, setLanguage, setOnUtteranceCompletedListener, setPitch, speak
    @Override 
    public void onInit(int status) {
    	Locale locale = new Locale("spa", "MEX");
        if (status == TextToSpeech.SUCCESS) {
            setTtsListener(); 
       	 	tts.setPitch(0.5f);
            switch (tts.isLanguageAvailable(locale))
            { 
                case TextToSpeech.LANG_AVAILABLE:
                case TextToSpeech.LANG_COUNTRY_AVAILABLE:
                case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
                    Log.d(TAG, "SUPPORTED");
                    tts.setLanguage(locale);
                    break; 
                case TextToSpeech.LANG_MISSING_DATA:
                    Log.d(TAG, "MISSING_DATA");
                    // missing data, install it 
                    Intent installIntent = new Intent();
                    installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                    startActivity(installIntent);

6
CodeRank
This code example shows how to use the following methods:isLanguageAvailable, setLanguage, setOnUtteranceCompletedListener, setOnUtteranceProgressListener, speak
    @SuppressWarnings("deprecation") 
    @Override 
    public void onInit(int initStatus) {
        if (initStatus == TextToSpeech.SUCCESS) { 
            hashMap.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "speechMessage"); 
            if (myTTS.isLanguageAvailable(Locale.UK) == TextToSpeech.LANG_COUNTRY_AVAILABLE) { 
                myTTS.setLanguage(Locale.UK); 
            } 
            if (Build.VERSION.SDK_INT >= 15) { 
                myTTS.setOnUtteranceProgressListener(new UtteranceProgressListener() { 
                    @Override 
                    public void onStart(String s) { 
 
                    } 
 
                    @Override 
                    public void onDone(String s) { 
                        onComplete(); 
                    } 
 

6
CodeRank
This code example shows how to use the following methods:getFeatures, getLanguage, isLanguageAvailable, speak
        } 
        return null; 
    } 
 
    private boolean isNetworkRequiredForSynthesis() { 
        Set<String> features = mTts.getFeatures(mTts.getLanguage());
        return features.contains(TextToSpeech.Engine.KEY_FEATURE_NETWORK_SYNTHESIS) &&
                !features.contains(TextToSpeech.Engine.KEY_FEATURE_EMBEDDED_SYNTHESIS);
    } 
 
    private void onSampleTextReceived(int resultCode, Intent data) {
        String sample = getDefaultSampleString();
 
        if (resultCode == TextToSpeech.LANG_AVAILABLE && data != null) {
            if (data != null && data.getStringExtra("sampleText") != null) {
                sample = data.getStringExtra("sampleText");
            } 
            if (DBG) Log.d(TAG, "Got sample text: " + sample);
        } else { 
            if (DBG) Log.d(TAG, "Using default sample text :" + sample);

6
CodeRank
This code example shows how to use the following methods:isLanguageAvailable, setLanguage, setSpeechRate
 
    @Override 
    public void onInit(int status) {
        if(status == TextToSpeech.SUCCESS) {
            Locale locale = Locale.US;
            if(this.textToSpeech.isLanguageAvailable(locale) >= TextToSpeech.LANG_AVAILABLE) {
                this.textToSpeech.setLanguage(locale);
                this.textToSpeech.setSpeechRate( (float) 0.8);
            } 
            else { 
                Log.e("TTS", "Not support locale.");
            } 
        } 
        else { 
            Log.e("TTS", "Init error.");
        }  
    } 
     
    public void renderReuslt( String userInput ){
        View resultContainer = (View)findViewById( R.id.PronounceResultContainer); 
5
CodeRank
This code example shows how to use the following methods:isLanguageAvailable, isSpeaking, speak, stop
	 *  
	 * @return true, if locale is available and supported 
	 */ 
	public boolean checkTTSSupportLanguage() { 
		Locale currentLocale = Locale.getDefault();
		return mTts.isLanguageAvailable(currentLocale) == TextToSpeech.LANG_MISSING_DATA
				|| mTts.isLanguageAvailable(currentLocale) == TextToSpeech.LANG_NOT_SUPPORTED ? false
				: true; 
	} 
 
	/** 
	 * Check keyguard screen is showing or in restricted key input mode . 
	 *  
	 * @return true, if in keyguard restricted input mode 
	 */ 
	public boolean checkKeyguardMode() { 
		getApplicationContext(); 
		KeyguardManager kgMgr = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
		return kgMgr.inKeyguardRestrictedInputMode();
	} 

5
CodeRank
This code example shows how to use the following methods:isLanguageAvailable, setLanguage, setOnUtteranceCompletedListener, setPitch
	    @Override 
	    public void onInit(int status) {
	    	Locale locale = new Locale("en", "EN");
	        if (status == TextToSpeech.SUCCESS) {
	            setTtsListener(); 
	       	 	tts.setPitch(0.5f);
	            switch (tts.isLanguageAvailable(locale))
	            { 
	                case TextToSpeech.LANG_AVAILABLE:
	                case TextToSpeech.LANG_COUNTRY_AVAILABLE:
	                case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
	                    Log.d(TAGsp, "SUPPORTED");
	                    tts.setLanguage(locale);
	                    break; 
	                case TextToSpeech.LANG_MISSING_DATA:
	                    Log.d(TAGsp, "MISSING_DATA");
	                    // missing data, install it 
	                    Intent installIntent = new Intent();
	                    installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
	                    startActivity(installIntent);

5
CodeRank
This code example shows how to use the following methods:isLanguageAvailable, setLanguage, setOnUtteranceProgressListener
	} 
 
	@Override 
	public void onInit(int status) {
		// TODO Auto-generated method stub 
		this.tts.setOnUtteranceProgressListener(this);
		if(TextToSpeech.SUCCESS == status){
			Locale locale = Locale.JAPAN;
			if(this.tts.isLanguageAvailable(locale) >= TextToSpeech.LANG_AVAILABLE){
				this.tts.setLanguage(locale);
				Log.d("test","language set");
			}else{ 
				 
				Log.d("", "Error setlocal");
			} 
		}else{ 
			Log.d("","error init");
		} 
	} 
	 
5
CodeRank

Related TextToSpeech isLanguageAvailable Questions & Answers:

isLanguageAvailable Method Overview
Checks if the specified language as represented by the Locale is available and supported.
See Code Examples for other Android TextToSpeech Methods: