Skip to content

Commit

Permalink
TextToSpeechAPI: Make stream configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed Apr 23, 2016
1 parent 0fd66d3 commit 151717e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/src/main/java/com/termux/api/TextToSpeechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ protected void onHandleIntent(final Intent intent) {
final String speechEngine = intent.getStringExtra("engine");
final float speechPitch = intent.getFloatExtra("pitch", 1.0f);

int streamToUseInt = AudioManager.STREAM_NOTIFICATION;
String streamToUseString = intent.getStringExtra("stream");
if (streamToUseString != null) {
switch (streamToUseString) {
case "NOTIFICATION": streamToUseInt = AudioManager.STREAM_NOTIFICATION; break;
case "ALARM": streamToUseInt = AudioManager.STREAM_ALARM; break;
case "MUSIC": streamToUseInt = AudioManager.STREAM_MUSIC; break;
case "RING": streamToUseInt = AudioManager.STREAM_RING; break;
case "SYSTEM": streamToUseInt = AudioManager.STREAM_SYSTEM; break;
case "VOICE_CALL": streamToUseInt = AudioManager.STREAM_VOICE_CALL; break;
}
}
final int streamToUse = streamToUseInt;

mTts = new TextToSpeech(this, new OnInitListener() {
@Override
public void onInit(int status) {
Expand Down Expand Up @@ -133,7 +147,7 @@ public void onDone(String utteranceId) {

String utteranceId = "utterance_id";
Bundle params = new Bundle();
params.putInt(Engine.KEY_PARAM_STREAM, AudioManager.STREAM_NOTIFICATION);
params.putInt(Engine.KEY_PARAM_STREAM, streamToUse);
params.putString(Engine.KEY_PARAM_UTTERANCE_ID, utteranceId);

int submittedUtterances = 0;
Expand Down

0 comments on commit 151717e

Please sign in to comment.