TextToSpeech shutdown - 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 shutdown method.

This code example shows how to use the following methods:shutdown
    /** 
     * Has to be called in onDestroy of the activity that uses this instance of VoiceOutputAssistant. 
     */ 
    public void onDestroy() { 
        if (mTts != null && isTTSInitialized) {
            mTts.shutdown();
            mTts = null;
            isTTSInitialized = false;
        } 
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:shutdown, getCurrentEngine
        // Keep track of the previous engine that was being used. So that 
        // we can reuse the previous engine. 
        // 
        // Note that if TextToSpeech#getCurrentEngine is not null, it means at 
        // the very least that we successfully bound to the engine service. 
        mPreviousEngine = mTts.getCurrentEngine();
 
        // Step 1: Shut down the existing TTS engine. 
        if (mTts != null) {
            try { 
                mTts.shutdown();
                mTts = null;
            } catch (Exception e) {
                Log.e(TAG, "Error shutting down TTS engine" + e);
            } 
        } 
 
        // Step 2: Connect to the new TTS engine. 
        // Step 3 is continued on #onUpdateEngine (below) which is called when 
        // the app binds successfully to the engine. 
6
CodeRank
This code example shows how to use the following methods:setLanguage, setOnUtteranceCompletedListener, shutdown, stop
    } 
     
    @Override 
    public void onDestroy() { 
        if (mTts != null) {
            mTts.stop();
            mTts.shutdown();
        } 
        super.onDestroy(); 
    } 
 
    public void onInit(int status) {
        if (status == TextToSpeech.SUCCESS) {
            int result = mTts.setLanguage(Locale.ENGLISH);
            if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED)
            	this.onDestroy();
            mTts.setOnUtteranceCompletedListener(this);
        } 
    } 
 

6
CodeRank
This code example shows how to use the following methods:shutdown
    } 
    public void shutdownTTS() { 
        Log.i(TAG, "Shutting Down TextToSpeech...");
 
        mSpeakingEngineAvailable = false;
        mTts.shutdown();
        Log.i(TAG, "TextToSpeech Shut Down.");
 
    } 
    public void say(String text) {
        if (mSpeak && mSpeakingEngineAvailable) {
            mTts.speak(text,
                    TextToSpeech.QUEUE_ADD,  // Drop all pending entries in the playback queue.
                    null); 
        } 
    } 
 
    // Implements TextToSpeech.OnInitListener. 
    public void onInit(int status) {
        // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. 
6
CodeRank
This code example shows how to use the following methods:shutdown, stop
 
    @Override 
    public void onDestroy() { 
        // Don't forget to shutdown! 
        if (mTts != null) {
            mTts.stop();
            mTts.shutdown();
        } 
 
        super.onDestroy(); 
    } 
 
    // Implements TextToSpeech.OnInitListener. 
    public void onInit(int status) {
        // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. 
        if (status == TextToSpeech.SUCCESS) {
            // Set preferred language to US english. 
            // Note that a language may not be available, and the result will indicate this. 
            int result = mTts.setLanguage(Locale.US);
            // Try this someday for some interesting results. 
6
CodeRank
This code example shows how to use the following methods:shutdown
     */ 
    @Override 
    public void onDestroy() { 
        super.onDestroy(); 
        if (mTextToSpeechInitialized) {
            mTts.shutdown();
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:shutdown, stop
 
    @Override 
    public void onDestroy() { 
        // Don't forget to shutdown! 
        if (mTts != null) {
            mTts.stop();
            mTts.shutdown();
        } 
 
        super.onDestroy(); 
    } 
 
    // Implements TextToSpeech.OnInitListener. 
    public void onInit(int status) {
        // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. 
        if (status == TextToSpeech.SUCCESS) {
            // Set preferred language to US english. 
            // Note that a language may not be available, and the result will indicate this. 
            int result = mTts.setLanguage(Locale.US);
            // Try this someday for some interesting results. 
5
CodeRank
This code example shows how to use the following methods:shutdown
		vibrate.cancel();
	} 
	 
	private void endAccess() { 
		vibrate.cancel();
		tts.shutdown();
	} 
	 
	private void doClick(AccessibilityEvent event) {
		vibrate.vibrate(VIBRATEPATTERN, -1);
		tts.speak("Click", 2, null);
	}	 
} 
6
CodeRank
This code example shows how to use the following methods:shutdown
			 
			int n = (int)(Math.random() * phrases.size());
			myTTS.speak(phrases.get(n), TextToSpeech.QUEUE_FLUSH, null);
 
		} else if (status == TextToSpeech.ERROR) {
			myTTS.shutdown();
		} 
	} 
} 
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

Related TextToSpeech shutdown Questions & Answers:

Other TextToSpeech shutdown Examples

45:			if (tts != null) {
46:				tts.stop();
47:				tts.shutdown();
48:			}
49:			super.onDestroy();

Read More

shutdown Method Overview
Releases the resources used by the TextToSpeech engine.
See Code Examples for other Android TextToSpeech Methods: