FileDocCategorySizeDatePackage
TextToSpeechICSMR1.javaAPI DocAndroid 5.1 API2794Thu Mar 12 22:22:56 GMT 2015android.support.v4.speech.tts

TextToSpeechICSMR1

public class TextToSpeechICSMR1 extends Object
Helper class for TTS functionality introduced in ICS MR1

Fields Summary
public static final String
KEY_FEATURE_EMBEDDED_SYNTHESIS
public static final String
KEY_FEATURE_NETWORK_SYNTHESIS
Constructors Summary
Methods Summary
static java.util.SetgetFeatures(android.speech.tts.TextToSpeech tts, java.util.Locale locale)
Call {@link TextToSpeech#getFeatures} if available.

return
{@link TextToSpeech#getFeatures} or null on older devices.

        if (android.os.Build.VERSION.SDK_INT >=
                android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            return tts.getFeatures(locale);
        }
        return null;
    
static voidsetUtteranceProgressListener(android.speech.tts.TextToSpeech tts, android.support.v4.speech.tts.TextToSpeechICSMR1$UtteranceProgressListenerICSMR1 listener)
Call {@link TextToSpeech#setOnUtteranceProgressListener} if ICS-MR1 or newer. On pre ICS-MR1 devices,{@link TextToSpeech#setOnUtteranceCompletedListener} is used to emulate its behavior - at the end of synthesis we call {@link UtteranceProgressListenerICSMR1#onStart(String)} and {@link UtteranceProgressListenerICSMR1#onDone(String)} one after the other. Errors can't be detected.


       
          
          
          
    

                                                
       
               
        if (android.os.Build.VERSION.SDK_INT >=
                android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            tts.setOnUtteranceProgressListener(new UtteranceProgressListener() {
                @Override
                public void onStart(String utteranceId) {
                    listener.onStart(utteranceId);
                }

                @Override
                public void onError(String utteranceId) {
                    listener.onError(utteranceId);
                }

                @Override
                public void onDone(String utteranceId) {
                    listener.onDone(utteranceId);
                }
            });
        } else {
            tts.setOnUtteranceCompletedListener(new OnUtteranceCompletedListener() {
                @Override
                public void onUtteranceCompleted(String utteranceId) {
                    // Emulate onStart. Clients are expecting it will happen.
                    listener.onStart(utteranceId);
                    listener.onDone(utteranceId);
                }
            });
        }