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

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:stop
		tts = new TextToSpeech(this, this);
		vibrate = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
	} 
	 
	private void stopAccess() { 
		tts.stop();
		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, 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:isSpeaking, speak, stop
public class TTSComponent extends Fragment implements TTS, OnInitListener {
    private TextToSpeech tts;
     
    @Override 
    public void speech(String text) {
        if (tts.isSpeaking()) {
            tts.stop();
        } 
 
        tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return new View(getActivity());
    } 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
6
CodeRank
This code example shows how to use the following methods:isSpeaking, setOnUtteranceCompletedListener, setPitch, setSpeechRate, speak
		 
	@Kroll.method 
	public boolean isSpeaking() { 
		Log.d(LCAT, "isSpeaking" );
		if (initialized) {
			return tts.isSpeaking();
		} 
		return false; 
	} 
	 
	@Kroll.method 
	public boolean speak(String text, @Kroll.argument(optional = true) String utteranceId) {
		Log.d(LCAT, "speak " + text);
		if (initialized) {
			if (0 < text.length()) {
				if (tts.setPitch(getPitch()) == TextToSpeech.ERROR) {
					Log.e("TTS", "Ptich(" + getPitch() + ") set error.");
				} 
				if (tts.setSpeechRate(getRate()) == TextToSpeech.ERROR) {
					Log.e("TTS", "Speech rate(" + getRate() + ") set 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. 
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:shutdown, stop
        mTts.stop();
    } 
 
    public void shutDown() { 
        if (mTts != null) {
            mTts.stop();
            mTts.shutdown();
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:shutdown, stop
        }               
    } 
    public void onDestroy() { 
        // Don't forget to shutdown! 
        if (mTts != null) {
            mTts.stop();
            mTts.shutdown();
        } 
        super.onDestroy(); 
    } 
    public void onInit(int status) {
        if (status == TextToSpeech.SUCCESS) {
            int result = mTts.setLanguage(Locale.US);
            if (result == TextToSpeech.LANG_MISSING_DATA ||
                result == TextToSpeech.LANG_NOT_SUPPORTED) {
                Log.e(TAG, "Language is not available.");
            } else { 
    			//mTts.speak("No success."); 
            } 
        } else { 
5
CodeRank
This code example shows how to use the following methods:shutdown, stop
    } 
 
    @Override 
    public void onDestroy() { 
        if (mTts != null) {
            mTts.stop();
            mTts.shutdown();
        } 
        super.onDestroy(); 
    } 
 
} 
5
CodeRank

Related TextToSpeech stop Questions & Answers:

Other TextToSpeech stop Examples

44:			// Don't forget to shutdown tts!
45:			if (tts != null) {
46:				tts.stop();
47:				tts.shutdown();
48:			}

Read More

stop Method Overview
Interrupts the current utterance (whether played or rendered to file) and discards other utterances in the queue.
See Code Examples for other Android TextToSpeech Methods: