Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use system tts pitch/rate by default #750

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/src/main/java/com/termux/api/apis/TextToSpeechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ protected void onHandleIntent(final Intent intent) {
final String speechRegion = intent.getStringExtra("region");
final String speechVariant = intent.getStringExtra("variant");
final String speechEngine = intent.getStringExtra("engine");
final float speechPitch = intent.getFloatExtra("pitch", 1.0f);
final float speechPitch = intent.getFloatExtra("pitch", 0.0f);
final float speechRate = intent.getFloatExtra("rate", 0.0f);

// STREAM_MUSIC is the default audio stream for TTS, see:
// http://stackoverflow.com/questions/6877272/what-is-the-default-audio-stream-of-tts/6979025#6979025
Expand Down Expand Up @@ -172,8 +173,13 @@ public void onDone(String utteranceId) {
}
}

mTts.setPitch(speechPitch);
mTts.setSpeechRate(intent.getFloatExtra("rate", 1.0f));
if (speechPitch != 0f) {
mTts.setPitch(speechPitch);
}

if (speechRate != 0f) {
mTts.setSpeechRate(speechRate);
}

String utteranceId = "utterance_id";
Bundle params = new Bundle();
Expand Down