mirror of
https://github.com/danog/termux-api.git
synced 2024-11-26 20:04:42 +01:00
TextToSpeechAPI: Make stream configurable
This commit is contained in:
parent
0fd66d37e3
commit
151717e2fb
@ -50,6 +50,20 @@ public class TextToSpeechAPI {
|
||||
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) {
|
||||
@ -133,7 +147,7 @@ public class TextToSpeechAPI {
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user