Merge change 3528 into donut

* changes:
  Simplify the TTS for Donut release
This commit is contained in:
Android (Google) Code Review
2009-06-09 08:15:14 -07:00
2 changed files with 76 additions and 127 deletions

View File

@@ -27,10 +27,6 @@ import android.content.Intent;
* {@hide} * {@hide}
*/ */
interface ITts { interface ITts {
void setEngine(in String engineName, in String[] requestedLanguages, in int strictness);
void setEngineWithIntent(in Intent engineIntent);
void setSpeechRate(in int speechRate); void setSpeechRate(in int speechRate);
void speak(in String text, in int queueMode, in String[] params); void speak(in String text, in int queueMode, in String[] params);
@@ -56,4 +52,6 @@ interface ITts {
void registerCallback(ITtsCallback cb); void registerCallback(ITtsCallback cb);
void unregisterCallback(ITtsCallback cb); void unregisterCallback(ITtsCallback cb);
void playSilence(in long duration, in int queueMode, in String[] params);
} }

View File

@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener; import android.media.MediaPlayer.OnCompletionListener;
@@ -106,7 +105,6 @@ public class TtsService extends Service implements OnCompletionListener {
private final ReentrantLock speechQueueLock = new ReentrantLock(); private final ReentrantLock speechQueueLock = new ReentrantLock();
private final ReentrantLock synthesizerLock = new ReentrantLock(); private final ReentrantLock synthesizerLock = new ReentrantLock();
// TODO support multiple SpeechSynthesis objects
private SynthProxy nativeSynth; private SynthProxy nativeSynth;
@Override @Override
@@ -114,15 +112,21 @@ public class TtsService extends Service implements OnCompletionListener {
super.onCreate(); super.onCreate();
Log.i("TTS", "TTS starting"); Log.i("TTS", "TTS starting");
// TODO: Make this work when the settings are done in the main Settings // TODO: Make this work when the settings are done in the main Settings
// app. // app.
prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs = PreferenceManager.getDefaultSharedPreferences(this);
// TODO: This should be changed to work by requesting the path PackageManager pm = this.getPackageManager();
// from the default engine. String soLibPath = "";
nativeSynth = new SynthProxy(prefs.getString("engine_pref", "")); try {
soLibPath = pm.getApplicationInfo("com.svox.pico", 0).dataDir;
} catch (NameNotFoundException e) {
// This exception cannot actually happen as com.svox.pico is
// included with the system image.
e.printStackTrace();
}
soLibPath = soLibPath + "/lib/libttspico.so";
nativeSynth = new SynthProxy(soLibPath);
mSelf = this; mSelf = this;
mIsSpeaking = false; mIsSpeaking = false;
@@ -170,35 +174,6 @@ public class TtsService extends Service implements OnCompletionListener {
nativeSynth.setLanguage(lang); nativeSynth.setLanguage(lang);
} }
private void setEngine(String engineName, String[] requestedLanguages,
int strictness) {
// TODO: Implement engine selection code here.
Intent engineIntent = new Intent(
"android.intent.action.START_TTS_ENGINE");
if (engineName != null) {
engineIntent.addCategory("android.intent.action.tts_engine."
+ engineName);
}
for (int i = 0; i < requestedLanguages.length; i++) {
engineIntent.addCategory("android.intent.action.tts_lang."
+ requestedLanguages[i]);
}
ResolveInfo[] enginesArray = new ResolveInfo[0];
PackageManager pm = getPackageManager();
enginesArray = pm.queryIntentActivities(engineIntent, 0).toArray(
enginesArray);
}
private void setEngine(Intent engineIntent) {
// TODO: Implement engine selection code here.
}
private int getEngineStatus() {
// TODO: Proposal - add a sanity check method that
// TTS engine plugins must implement.
return 0;
}
/** /**
* Adds a sound resource to the TTS. * Adds a sound resource to the TTS.
* *
@@ -436,8 +411,7 @@ public class TtsService extends Service implements OnCompletionListener {
if (sr == null) { if (sr == null) {
if (currentSpeechItem.mType == SpeechItem.SPEECH) { if (currentSpeechItem.mType == SpeechItem.SPEECH) {
// TODO: Split text up into smaller chunks before accepting // TODO: Split text up into smaller chunks before accepting
// them // them for processing.
// for processing.
speakInternalOnly(currentSpeechItem.mText, speakInternalOnly(currentSpeechItem.mText,
currentSpeechItem.mParams); currentSpeechItem.mParams);
} else { } else {
@@ -575,30 +549,6 @@ public class TtsService extends Service implements OnCompletionListener {
mCallbacks.unregister(cb); mCallbacks.unregister(cb);
} }
/**
* Gives a hint about the type of engine that is preferred.
*
* @param selectedEngine
* The TTS engine that should be used
*/
public void setEngine(String engineName, String[] supportedLanguages,
int strictness) {
mSelf.setEngine(engineName, supportedLanguages, strictness);
}
/**
* Specifies exactly what the engine has to support. Will always be
* considered "strict"; can be used for implementing
* optional/experimental features that are not supported by all engines.
*
* @param engineIntent
* An intent that specifies exactly what the engine has to
* support.
*/
public void setEngineWithIntent(Intent engineIntent) {
mSelf.setEngine(engineIntent);
}
/** /**
* Speaks the given text using the specified queueing mode and * Speaks the given text using the specified queueing mode and
* parameters. * parameters.
@@ -658,7 +608,6 @@ public class TtsService extends Service implements OnCompletionListener {
mSelf.playSilence(duration, queueMode, speakingParams); mSelf.playSilence(duration, queueMode, speakingParams);
} }
/** /**
* Stops all speech output and removes any utterances still in the * Stops all speech output and removes any utterances still in the
* queue. * queue.
@@ -741,16 +690,18 @@ public class TtsService extends Service implements OnCompletionListener {
mSelf.setSpeechRate(speechRate); mSelf.setSpeechRate(speechRate);
} }
// TODO: Fix comment about language
/** /**
* Sets the speech rate for the TTS. Note that this will only have an * Sets the speech rate for the TTS. Note that this will only have an
* effect on synthesized speech; it will not affect pre-recorded speech. * effect on synthesized speech; it will not affect pre-recorded speech.
* *
* @param language * @param language
* The language to be used. The languages are specified by * Language values are based on the Android conventions for
* their IETF language tags as defined by BCP 47. This is the * localization as described in the Android platform
* same standard used for the lang attribute in HTML. See: * documentation on internationalization. This implies that
* http://en.wikipedia.org/wiki/IETF_language_tag * language data is specified in the format xx-rYY, where xx
* is a two letter ISO 639-1 language code in lowercase and
* rYY is a two letter ISO 3166-1-alpha-2 language code in
* uppercase preceded by a lowercase "r".
*/ */
public void setLanguage(String language) { public void setLanguage(String language) {
mSelf.setLanguage(language); mSelf.setLanguage(language);