Skip to content

TTS fixes

J. Fronny requested to merge JFronny/shosetsu:main into main

This PR aims to address a number of issues in the current TTS implementation:

  • The TTS service cannot be discovered on recent android versions.
    This is fixed by adding android.intent.action.TTS_SERVICE to the manifest as is suggested in the android docs.
  • Text sometimes exceeds MaxSpeechInputLength, causing it to not be spoken.
    This is fixed by splitting the text, preferably at the end of a sentence (this is implemented with a simple but not necessarily accurate heuristic)
  • HTML is passed directly to TTS, causing it to speak it out loud.
    This is fixed by using Jsoup (which seems to be available?) to convert it to plain text.
  • isTTSPlaying is never updated, meaning playback can't be stopped.
    This is fixed by implementing an UtteranceProgressListener that updates the value (and prints errors).
  • The TTS language is chosen based on the system locale, which is often not the language you actually want.
    Instead of a proper fix (which would be cumbersome, since it would have to either detect the language or ask the user for every novel),
    I have alleviated this issue a bit by adding a localeConfig, allowing the user to configure one app language instead of forcing the system language.
  • Although pitch and speed settings are in the code, they are not exposed in the UI, preventing the user from changing them even from the system settings.
    This is addressed by adding a UI for them. Since FloatSliderSettingContent only allows int ranges, the value of the setting is the actual factor times ten.
Edited by J. Fronny

Merge request reports