0

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.

4

1 回答 1

0

CheckVoiceData是必要的,因为它可能由愿意知道引擎是否可以工作的客户调用。我认为你至少可以在没有其他两个的情况下生活一段时间。

    <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>

CheckVoiceData.onCreate()你会做这样的事情:

    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();

有效语言字符串的一个示例是"eng-USA".

于 2013-03-01T10:26:15.373 回答