TextToSpeech getLanguage - 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 getLanguage 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: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:areDefaultsEnforced, getDefaultEngine, getLanguage, shutdown
 
	@SuppressWarnings("deprecation") 
	private void getDataAboutSound(Context ct) {
		// TTS 
		try { 
			TextToSpeech mTts = new TextToSpeech(ct, null);
			if (mTts != null) {
				results.put("TTS supported", "Yes");
				results.put("TTS defaults enforced", String.valueOf(mTts.areDefaultsEnforced()));
				results.put("TTS default engine", mTts.getDefaultEngine());
				Locale tmpLocale = mTts.getLanguage();
				results.put("TTS default language", tmpLocale.getLanguage());
				results.put("TTS default country", tmpLocale.getCountry());
				if (Build.VERSION.SDK_INT>=14) {
 
					mTts.shutdown();
				} 
			}  
		} catch (Exception e) {
			results.put("TTS supported", "No:\n Error:" + e.toString());
		} 
5
CodeRank
This code example shows how to use the following methods:getDefaultEngine, getLanguage, speak
	} 
 
	// Fra TextToSpeech.OnInitListener 
	public void onInit(int status) {
		if (status == TextToSpeech.SUCCESS) {
			udtalKnap.setText("TTS klar for " + tts.getLanguage()
					+ "\nMotor: " + tts.getDefaultEngine());
			udtalKnap.setEnabled(true);
			//tts.addSpeech("jeg bremser hårdt", getPackageName(), R.raw.jeg_bremser_haardt); 
 
			if (friskStart) {
				tts.speak("Android-Elementers eksempel på text til tale er klar.", TextToSpeech.QUEUE_ADD, null);
			} 
			// Vis tastaturet 
			InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
			imm.showSoftInput(udtaleTekst, InputMethodManager.SHOW_FORCED);
		} else { 
			udtalKnap.setText("Kunne ikke indlæse TTS");
		} 
	} 
5
CodeRank
This code example shows how to use the following methods:getDefaultEngine, getLanguage, setOnUtteranceCompletedListener
 
	public void onInit(int status) {
		// Now that the TTS engine is ready, we enable the button 
		if( status == TextToSpeech.SUCCESS) {
			speakBtn.setEnabled(true);
			Locale loc = mTts.getLanguage();
            Log.v(TAG, "default engine: " + mTts.getDefaultEngine());
            Log.v(TAG, "current language/locale: " + loc.getDisplayName());
            Log.v(TAG, "current ISO3 language: " + loc.getISO3Language());
            Log.v(TAG, "current ISO3 country: " + loc.getISO3Country());
            Log.v(TAG, "current language: " + loc.getLanguage());
            Log.v(TAG, "current country: " + loc.getCountry());
            // mTts.setLanguage(new Locale("fr")); 
			mTts.setOnUtteranceCompletedListener(this);
		} 
	} 
 
	@Override 
	public void onPause() 
	{ 
5
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);

5
CodeRank
This code example shows how to use the following methods:getLanguage
	} 
	 
	@Kroll.method 
	public String getLanguage()
	{ 
		Locale locale = tts.getLanguage();
		Log.d(LCAT, "getLanguage:" + locale.toString());
		return locale.toString();
	} 
		 
	@Kroll.method 
	public boolean isSpeaking() { 
		Log.d(LCAT, "isSpeaking" );
		if (initialized) {
			return tts.isSpeaking();
		} 
		return false; 
	} 
	 
	@Kroll.method 
3
CodeRank
getLanguage Method Overview
Returns a Locale instance describing the language currently being used for synthesis requests sent to the TextToSpeech engine.
See Code Examples for other Android TextToSpeech Methods: