tts Service explanation in android

4.2k views Asked by At

I have questions regarding the implementation of tts service for android. Here's the deal:

-I've looked over Flite code and I see that service is require to have these 3 activities:

<activity
        android:name=".DownloadVoiceData"
        android:label="@string/flite_voice_manager"
        android:theme="@android:style/Theme.Holo" 
        android:configChanges="orientation">
        <intent-filter>
            <action android:name="android.speech.tts.engine.INSTALL_TTS_DATA" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".CheckVoiceData"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" >
        <intent-filter>
            <action android:name="android.speech.tts.engine.CHECK_TTS_DATA" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".GetSampleText"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" >
        <intent-filter>
            <action android:name="android.speech.tts.engine.GET_SAMPLE_TEXT" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

The actual actions of these activities are self explainable, but I want to know: Are they mandatory, how they work .... I have google it but with no luck.

  1. Can anybody point out to some documentation where these activities are explained?

  2. Also, is there any documentation of tts service flow explained in detail?

Thanx in advance.

1

There are 1 answers

0
18446744073709551615 On

CheckVoiceData is necessary because it may be invoked by a client willing to know if the engine will work. I think you can live without the other two at least for some time.

    <activity android:name=".CheckVoiceData"
            android:theme="@android:style/Theme.NoDisplay">
        <intent-filter>
            <action android:name="android.speech.tts.engine.CHECK_TTS_DATA" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

In CheckVoiceData.onCreate() you will do something like this:

    ArrayList<String> askedToCheck = intent.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_CHECK_VOICE_DATA_FOR);
    // if it is null, they usually check and report all available languages.


    ArrayList<String> available = new ArrayList<String>();
    ArrayList<String> unavailable = new ArrayList<String>();

    //...

    Intent returnData = new Intent();
    returnData.putStringArrayListExtra(
            TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES, available);
    returnData.putStringArrayListExtra(
            TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES, unavailable);
    setResult(result, returnData);
    finish();

An example of a valid language string is "eng-USA".