加入我的TTS引擎到Android TTS Serivce像SAPI [英] add my TTS Engine to Android TTS Serivce like SAPI

查看:1027
本文介绍了加入我的TTS引擎到Android TTS Serivce像SAPI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了Android中我自己的TTS应用程序。有什么办法来部署我的TTS引擎到操作系统,而不是上运行的应用程序的TTS,让其他应用程序可以调用我的TTS?喜欢的东西SAPI在MS窗口。 SVOX能发动机打包为apk文件并安装后,它增加了新的发动机进的Andorid操作系统,不知道我该怎么做同样的。

I have developed my own TTS apps in Android. Is there any way to deploy my TTS engine into the OS instead on running the TTS apps, so that other apps can call my TTS? Something like SAPI in MS Window. SVOX can package the engine as apk and after installed, it adds new engines into the Andorid OS, not sure how can I do that same.

推荐答案

有关文本到语音转换引擎出现在可用服务的列表中,您需要添加相应的活动和明显的条目。

For your text-to-speech engine to show up in the list of available services, you'll need to add the appropriate activities and manifest entries.

有关API 14以上,则需要延长TextToSpeechService,你需要以下内容添加到您的清单:

For API 14 and above, you need to extend TextToSpeechService and you need to add the following to your manifest:

    <service
        android:name=".MyTextToSpeechService"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.TTS_SERVICE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data
            android:name="android.speech.tts"
            android:resource="@xml/tts_engine" />
    </service>

此引用RES / XML / tts_engine.xml,这应该是这样的:

This references res/xml/tts_engine.xml, which should look like this:

<?xml version="1.0" encoding="utf-8"?>
<tts-engine xmlns:android="http://schemas.android.com/apk/res/android"
    android:settingsActivity="com.example.MyTtsSettingsActivity" />

您还将需要添加各种配套活动。这里就是你将添加到您的清单:

You'll also need to add a variety of supporting activities. Here's what you'll be adding to your manifest:

    <activity
        android:name=".DownloadVoiceData"
        android:theme="@android:style/Theme.Dialog" >
        <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: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: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>
    <activity
        android:name=".TtsSettingsActivity"
        android:label="@string/tts_settings_label" >
        <intent-filter>
            <action android:name="android.speech.tts.engine.CONFIGURE_ENGINE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

    <!-- Legacy code for pre-ICS compatibility. -->
    <activity
        android:name=".MyTtsEngine"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.START_TTS_ENGINE" />
        </intent-filter>
    </activity>

    <provider
        android:name="com.googlecode.eyesfree.espeak.providers.SettingsProvider"
        android:authorities="com.googlecode.eyesfree.espeak.providers.SettingsProvider" />

如果你打算支持pre-ICS的Andr​​oid版本,你还需要一个共享库符合一个特定的API。

If you're planning on supporting pre-ICS versions of Android, you'll also need a shared library that conforms to a specific API.

我不会去到每一个活动的实施细节在这里,或到pre-ICS API,但你可以找到例子源$ C ​​$下的espeak的TTS引擎在Android端口: 的http:// code.google.com/p/eyes-free/source/browse/trunk/tts/espeak-tts/

I won't go into details of the implementation of each activity here, or into the pre-ICS API, but you can find examples in the source code for the Android port of eSpeak TTS engine: http://code.google.com/p/eyes-free/source/browse/trunk/tts/espeak-tts/

这篇关于加入我的TTS引擎到Android TTS Serivce像SAPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆