Adding the ability to specify the speech synthesis
engine to use for text-to-speech.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user