From 60dd360640a400d9b4a602160733281d284aaee5 Mon Sep 17 00:00:00 2001 From: Charles Chen Date: Thu, 7 Jan 2010 18:56:24 -0800 Subject: Enabling multiple apps to use different speech synthesis engines and not interfere with one another. --- packages/TtsService/src/android/tts/TtsService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'packages/TtsService/src') diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java index 23365c9..1efa5a3 100755 --- a/packages/TtsService/src/android/tts/TtsService.java +++ b/packages/TtsService/src/android/tts/TtsService.java @@ -744,6 +744,7 @@ public class TtsService extends Service implements OnCompletionListener { String country = ""; String variant = ""; String speechRate = ""; + String engine = ""; if (speechItem.mParams != null){ for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){ String param = speechItem.mParams.get(i); @@ -765,12 +766,17 @@ public class TtsService extends Service implements OnCompletionListener { } catch (NumberFormatException e) { streamType = DEFAULT_STREAM_TYPE; } + } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_ENGINE)) { + engine = speechItem.mParams.get(i + 1); } } } } // Only do the synthesis if it has not been killed by a subsequent utterance. if (mKillList.get(speechItem) == null) { + if (engine.length() > 0) { + setEngine(engine); + } if (language.length() > 0){ setLanguage("", language, country, variant); } @@ -825,6 +831,7 @@ public class TtsService extends Service implements OnCompletionListener { String country = ""; String variant = ""; String speechRate = ""; + String engine = ""; if (speechItem.mParams != null){ for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){ String param = speechItem.mParams.get(i); @@ -839,12 +846,17 @@ public class TtsService extends Service implements OnCompletionListener { variant = speechItem.mParams.get(i+1); } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){ utteranceId = speechItem.mParams.get(i+1); + } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_ENGINE)) { + engine = speechItem.mParams.get(i + 1); } } } } // Only do the synthesis if it has not been killed by a subsequent utterance. if (mKillList.get(speechItem) == null){ + if (engine.length() > 0) { + setEngine(engine); + } if (language.length() > 0){ setLanguage("", language, country, variant); } -- cgit v1.1