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

Release version 2.0 #5

Merged
merged 34 commits into from
Jun 17, 2020
Merged

Release version 2.0 #5

merged 34 commits into from
Jun 17, 2020

Conversation

drmfinlay
Copy link
Owner

@drmfinlay drmfinlay commented Jun 4, 2020

Closes #1, #2, #4, #6.

There are quite a few changes, mostly bug fixes and improvements, plus a few additions. There are still a few things I need to fix. I will update this post with a summary of the changes before merging.

Summary

  • Add menu item for reinitialising the TTS engine.
  • Add settings screen for setting and changing app-specific TTS settings.
  • Change minimum required Android version to Android 5.0 Lollipop.
  • Change output sound file names to use the '.wav' extension instead of '.mp4'.
  • Change the app to handle input lines and text files longer than Android's maximum speech input length.
  • Improve TTS initialisation and language handling.
  • Make TTS notifications display process of text synthesis.
  • Other bug fixes and improvements.

This is being done in an effort to simplify the TextToSpeech API
use.
- Replace checkTTS() method and usages with OnInitListener in
  SpeakerActivity classes.
- Add four SpeakerActivity methods for dialog events and override
  them in QuickShareActivity.
- Display a message if TTS initialisation fails.
- Display messages if the selected and/or default speaker languages
  are not available.
- Fallback on default language if the selected language is not
  available.
This is useful for applying changes to the TTS settings.
The icon is the built-in Android 'ic_menu_preferences' icon.
Notifications may not get dismissed automatically if the TTS engine
is reinitialised. This makes sure they are removed.
This is to simplify and have consistency between the listener
classes. Also for the next changes.
SpeakerEventListeners are able to check if speech synthesis is
stopping.
An application context should not be used for creating alert
dialogs. They seem to require a UI Context object, e.g. an
Activity.
This adds different messages for each error code that can be passed
to the UtteranceProgressListener.onError() method.
Re: #1.

Long lines like this are now split into multiple smaller lines of
reasonable length before they are passed to the TTS engine.

This has not been implemented for Speaker.synthesizeToFile() yet.
These tasks will not succeed if the app is slow to post
notifications or acquire audio focus, so we try to cancel them
asynchronously in roughly 300 ms time.

This is only an issue for onError() utterance events.
The current system locale is the preferred language as set in the
system settings. The app was previously falling back on the default
JVM locale, which doesn't change.
Show proper error messages if trying to synthesise text after TTS
engine initialisation failed or if TTS isn't ready.
@drmfinlay drmfinlay self-assigned this Jun 4, 2020
The main function in this file is joinWaveFiles(). It uses Java
File objects. Only compatible PCM wave files can be joined.

I have kept this implementation in a separate file without Android
imports so it can be used on other platforms.
Closes #1.

This works around Android's maximum speech input length for TTS
file synthesis. Long text files are now split up, synthesised into
smaller wave files and then joined back together as one larger wave
file after all parts are synthesised successfully.
In my testing, I have noticed some utterances give repeated events.
Using a set instead of a list works around that problem.
In this case, the single input file can just be written to the
output file.

This also handles the special case of a TTS engine that synthesises
sound files of a different type (e.g. MP3 instead of wave). I note
here that Android's TextToSpeech documentation makes no specific
reference to wave files. That said, I have not encountered any
other sound file type.
This required a few changes to the Speaker and SpeakerEventListener
classes as well as storing notification *builders* instead so the
existing notifications could be updated.
This is so utterance progress is shown in the notification when
reading text files. This should have been done in the first place
given that the TextToSpeech.speak() method is asynchronous.
This more makes sense because the class is only used via
inheritance, never directly.
This commit makes the following notable changes:
- Add Android support preference library (v7) as a dependency.
- Add settings fragment for changing the app's TTS settings.
- Add/change code in the ApplicationEx, SpeakerActivity and Speaker
  classes for applying the preferred TTS engine settings.
- Add four material design icons used in the settings fragment.
- Move code for opening system TTS settings into SpeakerActivity.
@drmfinlay drmfinlay changed the title Release version 1.1.0 Release version 2.0 Jun 15, 2020
@drmfinlay drmfinlay linked an issue Jun 15, 2020 that may be closed by this pull request
The app won't set the speech rate or pitch unless they are chosen
in the app's TTS settings.
This allows resetting the app's TTS settings so that the system
TTS settings will be used instead.
Many parts of Android's TextToSpeech API require at least this
version. In my view, supporting version 20 is not worth the many
conditional branches currently in the codebase.

As a side note, I cannot even create an emulator for SDK version 20
to test with!
This app and other text-to-speech client apps can be sent parcelled
exceptions via TextToSpeech class methods to be raised after being
decoded. In my experience, these exceptions have all been
NullPointerExceptions. They have only occurred for me on Android
Lollipop 5.0/5.1 and only with Voice-related methods such as
getVoice().

This change works around these errors by adding and using Speaker
properties that catch these exceptions and return empty/null
values.
@drmfinlay drmfinlay merged commit 4f1ff3c into master Jun 17, 2020
@drmfinlay drmfinlay deleted the develop branch June 17, 2020 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant