Android 生成自己的tts engine

2021-03-04  本文已影响0人  yunhen

创建一个类,继承于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>

这样 在,系统设置-文字转语音 里面能看到自己的app啦

上一篇 下一篇

猜你喜欢

热点阅读