TextToSpeech setOnUtteranceCompletedListener - 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 setOnUtteranceCompletedListener 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: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:setLanguage, setOnUtteranceCompletedListener, setSpeechRate, speak
    @Override 
    public void onInit(int status) {
        if (status == TextToSpeech.SUCCESS && mFact != null) {
            HashMap<String, String> callbackArgs = new HashMap<String, String>();
            callbackArgs.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, TTS_UTTERANCE_CALLBACK);
            mTts.setOnUtteranceCompletedListener(this);
            mTts.setLanguage(Locale.US);
            mTts.setSpeechRate(0.8f);
            mTts.speak(mFact, TextToSpeech.QUEUE_FLUSH, callbackArgs);
        } 
    } 
 
    @Override 
    protected void onDestroy() { 
        super.onDestroy(); 
        mTts.shutdown();
    } 
 
    private String getFactForWidget(int widgetID) {
        // Write the prefix to the SharedPreferences object for this widget 
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: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:setOnUtteranceCompletedListener, speak
			}}; 
	 	 
		myHandler.postDelayed(Runnable, Time);}
	 
	public void onInit(int status) {
		mTts.setOnUtteranceCompletedListener(this);
		myHashAlarm = new HashMap<String, String>();
        myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_ALARM));
        myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "Enonciation terminée");
		mTts.speak(Phrase,TextToSpeech.QUEUE_FLUSH, myHashAlarm);}
	 
	@Override 
	public void onUtteranceCompleted(String uttid) {Traitement();}
	 
	boolean Launch_son(String Son){
		try{int ID = getResources().getIdentifier(Son, "raw", "fr.nover.yana");
		 
			MediaPlayer mp = MediaPlayer.create(this, ID); 
			mp.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
			mp.setOnCompletionListener(new  MediaPlayer.OnCompletionListener() { 
5
CodeRank
This code example shows how to use the following methods:setLanguage, setOnUtteranceCompletedListener, setSpeechRate
 
	@Override 
	public void onInit(final int status) {
		Log.v("SMN", "tts init");
 
		talker.setOnUtteranceCompletedListener(new SpeechFinishedListener());
		talker.setLanguage(Locale.getDefault());
		talker.setSpeechRate(0.95f);
 
		new Thread() {
			@Override 
			public void run() { 
				try { 
					sleep(500);
				} catch (final InterruptedException e) {
					e.printStackTrace();
				} 
 
				synchronized (waitObject) {
					ready = true;
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

Related TextToSpeech setOnUtteranceCompletedListener Questions & Answers:

setOnUtteranceCompletedListener Method Overview
This method was deprecated in API level 15. Use setOnUtteranceProgressListener(UtteranceProgressListener) instead.
See Code Examples for other Android TextToSpeech Methods: