Adding the ability to specify the speech synthesis

engine to use for text-to-speech.
This commit is contained in:
Charles Chen
2009-11-18 16:34:32 -08:00
parent 6d5d55c103
commit b4fbe768f8
4 changed files with 67 additions and 1 deletions

View File

@@ -59,5 +59,7 @@ interface ITts {
int unregisterCallback(in String callingApp, ITtsCallback cb);
int playSilence(in String callingApp, in long duration, in int queueMode, in String[] params);
int playSilence(in String callingApp, in long duration, in int queueMode, in String[] params);
int setEngineByPackageName(in String enginePackageName);
}

View File

@@ -1254,4 +1254,44 @@ public class TextToSpeech {
}
}
/**
* Sets the speech synthesis engine to be used by its packagename.
*
* @param enginePackageName
* The packagename for the synthesis engine (ie, "com.svox.pico")
*
* @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
*/
public int setEngineByPackageName(String enginePackageName) {
synchronized (mStartLock) {
int result = TextToSpeech.ERROR;
if (!mStarted) {
return result;
}
try {
result = mITts.setEngineByPackageName(enginePackageName);
} catch (RemoteException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - setEngineByPackageName", "RemoteException");
e.printStackTrace();
mStarted = false;
initTts();
} catch (NullPointerException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - setEngineByPackageName", "NullPointerException");
e.printStackTrace();
mStarted = false;
initTts();
} catch (IllegalStateException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - setEngineByPackageName", "IllegalStateException");
e.printStackTrace();
mStarted = false;
initTts();
} finally {
return result;
}
}
}
}