创建一个类,继承于TextToSpeechService
res/下新建 xml目录,并新建文件tts_engine.xml
内容为
<?xml version="1.0" encoding="utf-8"?>
<tts-engine xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="xxx.xxx.MainActivity">
</tts-engine>
manifest.xml里增加
<service android:name=".MyTextToSpeechService"
android:label="ttsTestDemo"
>
<meta-data android:name="myTts" android:resource="@xml/tts_engine"/>
<intent-filter>
<action android:name="android.intent.action.TTS_SERVICE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
网友评论