Add my TTS Engine to Android TTS Serivce, e.g. SAPI

I developed my own TTS applications on Android. Is there a way to deploy my TTS engine to the OS instead of running TTS applications so that other applications can invoke my TTS? Something like SAPI in MS Window. SVOX can pack the engine as apk, and after installing it, it adds new engines to the Andorid OS, not sure how I can do the same.

+6
source share
1 answer

In order for your text-to-speech engine to appear in the list of available services, you need to add the appropriate actions and manifest entries.

For APIs 14 and above, you need to extend TextToSpeechService, and you need to add the following content to the 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> 

This refers to 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 also need to add various supporting actions. Here is what you add to the 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" /> 

If you plan to support Android versions prior to ICS, you will also need a shared library that matches the specific API.

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

+4
source

Source: https://habr.com/ru/post/904071/


All Articles