Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 883dbacb authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Fixing a bug with TTS that caused TTS to ignore the default settings...

Merge "Fixing a bug with TTS that caused TTS to ignore the default settings unless the user had set the defaults to always override app settings."
parents 31901cc0 6a8b73be
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -410,17 +410,17 @@ public class TextToSpeech {
        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID] = Engine.KEY_PARAM_UTTERANCE_ID;
        mCachedParams[Engine.PARAM_POSITION_ENGINE] = Engine.KEY_PARAM_ENGINE;

        mCachedParams[Engine.PARAM_POSITION_RATE + 1] =
                String.valueOf(Engine.DEFAULT_RATE);
        // initialize the language cached parameters with the current Locale
        Locale defaultLoc = Locale.getDefault();
        mCachedParams[Engine.PARAM_POSITION_LANGUAGE + 1] = defaultLoc.getISO3Language();
        mCachedParams[Engine.PARAM_POSITION_COUNTRY + 1] = defaultLoc.getISO3Country();
        mCachedParams[Engine.PARAM_POSITION_VARIANT + 1] = defaultLoc.getVariant();
        // Leave all defaults that are shown in Settings uninitialized so that
        // the values set in Settings will take effect if the application does
        // not try to change these settings itself.
        mCachedParams[Engine.PARAM_POSITION_RATE + 1] = "";
        mCachedParams[Engine.PARAM_POSITION_LANGUAGE + 1] = "";
        mCachedParams[Engine.PARAM_POSITION_COUNTRY + 1] = "";
        mCachedParams[Engine.PARAM_POSITION_VARIANT + 1] = "";
        mCachedParams[Engine.PARAM_POSITION_STREAM + 1] =
                String.valueOf(Engine.DEFAULT_STREAM);
        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID + 1] = "";
        mCachedParams[Engine.PARAM_POSITION_ENGINE + 1] = Engine.DEFAULT_SYNTH;
        mCachedParams[Engine.PARAM_POSITION_ENGINE + 1] = "";

        initTts();
    }
+17 −0
Original line number Diff line number Diff line
@@ -206,6 +206,9 @@ public class TtsService extends Service implements OnCompletionListener {

    private int setEngine(String enginePackageName) {
        String soFilename = "";
        if (isDefaultEnforced()) {
            enginePackageName = getDefaultEngine();
        }
        // The SVOX TTS is an exception to how the TTS packaging scheme works
        // because it is part of the system and not a 3rd party add-on; thus
        // its binary is actually located under /system/lib/
@@ -779,12 +782,19 @@ public class TtsService extends Service implements OnCompletionListener {
                    if (mKillList.get(speechItem) == null) {
                        if (engine.length() > 0) {
                            setEngine(engine);
                        } else {
                            setEngine(getDefaultEngine());
                        }
                        if (language.length() > 0){
                            setLanguage("", language, country, variant);
                        } else {
                            setLanguage("", getDefaultLanguage(), getDefaultCountry(),
                                    getDefaultLocVariant());
                        }
                        if (speechRate.length() > 0){
                            setSpeechRate("", Integer.parseInt(speechRate));
                        } else {
                            setSpeechRate("", getDefaultRate());
                        }
                        try {
                            sNativeSynth.speak(speechItem.mText, streamType);
@@ -864,12 +874,19 @@ public class TtsService extends Service implements OnCompletionListener {
                    if (mKillList.get(speechItem) == null){
                        if (engine.length() > 0) {
                            setEngine(engine);
                        } else {
                            setEngine(getDefaultEngine());
                        }
                        if (language.length() > 0){
                            setLanguage("", language, country, variant);
                        } else {
                            setLanguage("", getDefaultLanguage(), getDefaultCountry(),
                                    getDefaultLocVariant());
                        }
                        if (speechRate.length() > 0){
                            setSpeechRate("", Integer.parseInt(speechRate));
                        } else {
                            setSpeechRate("", getDefaultRate());
                        }
                        try {
                            sNativeSynth.synthesizeToFile(speechItem.mText, speechItem.mFilename);