Adding the ability to specify the speech synthesis
engine to use for text-to-speech.
This commit is contained in:
@@ -124607,6 +124607,19 @@
|
||||
<parameter name="params" type="java.util.HashMap<java.lang.String, java.lang.String>">
|
||||
</parameter>
|
||||
</method>
|
||||
<method name="setEngineByPackageName"
|
||||
return="int"
|
||||
abstract="false"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<parameter name="enginePackageName" type="java.lang.String">
|
||||
</parameter>
|
||||
</method>
|
||||
<method name="setLanguage"
|
||||
return="int"
|
||||
abstract="false"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1326,6 +1326,17 @@ public class TtsService extends Service implements OnCompletionListener {
|
||||
return mSelf.synthesizeToFile(callingApp, text, speakingParams, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the speech synthesis engine for the TTS by specifying its packagename
|
||||
*
|
||||
* @param packageName the packageName of the speech synthesis engine (ie, "com.svox.pico")
|
||||
*
|
||||
* @return SUCCESS or ERROR as defined in android.speech.tts.TextToSpeech.
|
||||
*/
|
||||
public int setEngineByPackageName(String packageName) {
|
||||
return mSelf.setEngine(packageName);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user