内置googletts并且内置中文语音包

先上补丁

diff --git a/frameworks/base/core/java/android/speech/tts/TextToSpeech.java b/frameworks/base/core/java/android/speech/tts/TextToSpeech.java
index 01562b3..99e7598 100644
--- a/frameworks/base/core/java/android/speech/tts/TextToSpeech.java
+++ b/frameworks/base/core/java/android/speech/tts/TextToSpeech.java
@@ -282,8 +282,8 @@ public class TextToSpeech {
          *         alone be the default.
          */
         @Deprecated
-        public static final String DEFAULT_ENGINE = "com.svox.pico";
-
+        //public static final String DEFAULT_ENGINE = "com.svox.pico";
+        public static final String DEFAULT_ENGINE = "com.google.android.tts";//luke add for default tts
         /**
          * Default audio stream used when playing synthesized speech.
          */
diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index fce2497..300de87 100644
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -217,4 +217,5 @@
 
     <!-- Default for Settings.System.VIBRATE_WHEN_RINGING -->
     <bool name="def_vibrate_when_ringing">false</bool>
+       <string name="default_tts" translatable="false">com.google.android.tts</string>
 </resources>
diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 3aae5e4..13875e1 100644
--- a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2443,6 +2443,9 @@ class DatabaseHelper extends SQLiteOpenHelper {
             loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT,
                     R.integer.def_sleep_timeout);
 
+                       loadStringSetting(stmt, Settings.Secure.TTS_DEFAULT_SYNTH,
+                                       R.string.default_tts);//luke add for deault tts
+
             /*
              * IMPORTANT: Do not add any more upgrade steps here as the global,
              * secure, and system settings are no longer stored in a database
diff --git a/vendor/ztl/preinstall/preinstall.mk b/vendor/ztl/preinstall/preinstall.mk
index 76a4bdd..43c033e 100644
--- a/vendor/ztl/preinstall/preinstall.mk
+++ b/vendor/ztl/preinstall/preinstall.mk
@@ -6,3 +6,6 @@ PRODUCT_COPY_FILES += \
 apk_files := $(shell ls $(LOCAL_PATH)/*.apk)
 
 PRODUCT_COPY_FILES += $(foreach file, $(apk_files), $(file):system/preinstall/$(notdir $(file)))
+
+#拷贝语音包文件夹.等下在yiansetting里面执行cp到tts目录下和改权限
+PRODUCT_COPY_FILES += $(call find-copy-subdir-files,*,$(LOCAL_PATH)/app_voices_greco_v15,system/preinstall/app_voices_greco_v15)

然后感谢这位仁兄的辛勤分析

GooglTTS中文包预置_flyfly程序媛-CSDN博客

当然我肯定不是完全转载,我会把这个步骤给分解出来.

0.下载googletts并且放到preinstall目录(实现预安装程序,请八仙过海吧)

1.打上面的补丁,主要是为了让系统默认选中该语音为默认tts

2.烧录固件完成后,自己写个textSpeech例子,发现...播报不了. 插网线.

3.发现可以播报,完了就

adb pull /data/user_de/0/com.google.android.tts ./ 把这个文件夹下的app_voices_greco_v15保存好.你就不用去csdn下载各种XXXX语音包了. 当然,我用的apk比较老.所以是app_voices_greco_v15

可能最新是v16或者17 18说不定.这里只是提供一种不用去csdn下载的自行提取办法.

然后就在你的预安装脚本把这个文件夹push到任何你喜欢的目录.

4.第一次开机启动,cp -r 到/data/user_de/0/com.google.android.tts 并且chmod 777 -R .(至于是用什么apk来执行这个,还是搞个什么脚本随便你们八仙过海)

5.不插网线也可以正常使用.

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值