Honor system pitch and fix English sample in TTS settings#2
Merged
Conversation
Pitch (dsp/PitchShifter): - Add a duration-preserving SOLA pitch shifter (time-stretch + resample) so the Android system pitch setting is honored. The default path (factor ~1.0) returns audio untouched, so normal playback is unchanged and free. - Wire into AvaTtsService: when pitch != default, synthesize the sentence, shift, then write; otherwise keep the streaming path. - Fix an index overflow in the resampler on long buffers (compute position directly in double precision instead of accumulating, with a bound guard). Found on device (ArrayIndexOutOfBounds at ~63k samples, factor 0.87). TTS settings sample (TtsDataCheckActivity): - GET_SAMPLE_TEXT now returns result code LANG_AVAILABLE instead of RESULT_OK. The settings screen only accepts the engine's sample when the code is LANG_AVAILABLE; with RESULT_OK it silently fell back to its built-in English string, which the Persian voice spoke as gibberish. Diagnostics: - Log the request rate/pitch and a text preview in onSynthesizeText. Verified on device (OnePlus Nord): "Play sample" now speaks Persian; pitch 0.79 applied with 65k frames delivered and no crash. Unit tests cover pitch up/down, duration preservation, and the large-buffer regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
AliRezaTaleghani
added a commit
that referenced
this pull request
Jun 11, 2026
Honor system pitch and fix English sample in TTS settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pitch (dsp/PitchShifter):
TTS settings sample (TtsDataCheckActivity):
Diagnostics:
Verified on device (OnePlus Nord): "Play sample" now speaks Persian; pitch 0.79 applied with 65k frames delivered and no crash. Unit tests cover pitch up/down, duration preservation, and the large-buffer regression.