TTS Speech rework#7357
Conversation
|
Seconded. Also, options to increase/decrease the speed of TTS narration would be great if possible, since the default speed is slower than most people speak 🙂 |
you got it |
notimaginative
left a comment
There was a problem hiding this comment.
I tested it on Mac and confirmed everything was still working. Apart from the issues noted obviously. I'd like to check and test the Linux changes as well and will do that when I have a bit more time.
However, one desperately needed addition is the ability to actually test the voice changes before saving them.
|
Regarding testing; The options UI framework doesn't really have a nice way to set that up as a separate control. I'd recommend carving out a special case for this option's selector to play a test whenever the value changes. |
I played around with this a bit, but it doesn't look like there's a way to do it. It's easy enough to add a test command to the change listener but that's only called when changes are saved. There doesn't appear to be any current mechanism to deal with control changes when they happen. I assume we'll have to push the test feature down the road, extend options manager to have such functionality, then circle back and add it for TTS. |
|
I did the requested changes. taylor when you have the time please take a look. two things to add:
Also, normally you are not going to want to use the espeak-ng voices, they are terrible, so Linux users should be able to remove the espeak-ng backend and install a neural one like PiperTTS to speech-dispatcher. I havent tested that myselft but the point of using speech-dispatcher is that it should work with any TTS backend. |
notimaginative
left a comment
There was a problem hiding this comment.
Everything looks good, except for one issue that I had to confirm. The voices cache is released properly in ttsvoice_change() however that is only ever fired if the voice control changes. This means that unless the voice control is accessed the memory used by the cache is never released.
So I recommend adding a generic fsspeech_cleanup() type of function (name it what makes sense) and move the clear and shrink_to_fit calls from ttsvoice_change() to this new function. Then call that function from ingame_options_close() to release any memory used by the cache when the options screen exits.
That should resolve the final issue that I see.
(Preferably this functionality would be added to OptionsBuilder directly to allow proper cleanup, plus support an enumerator cache internally which would have made this much easier, but that is well outside the scope of this PR)
|
Ok, added fsspeech_options_cleanup() that is called on ingame_options_close(). I checked that this is fact called on both during options saving and when there are no changes. |
|
|
||
| #include "options/OptionsManager.h" | ||
| #include "options/Option.h" | ||
| #include <sound/fsspeech.h> |
There was a problem hiding this comment.
This should use quotes instead of angle brackets.
An alternative to using the include here is to just add extern void fsspeech_options_cleanup(); immediately before the call to that function below. That may actually be preferred so that it's easier to remove that code in the future, assuming that the options code eventually gets modified to handle this stuff itself.
But either change works.
The objectives of this pr are:
Add TTS Speech options to ingame options settings. Incliding voice selection, voice rate, volume settings and select places were TTS is used
Add TTS Speech support to Linux OS by using speech-dispatcher/libspeechd-dev, this is done used dlopen and a small implementation of the lib types. In this way there is not additional dependency for compiling or in runtime, if speech-dispatcher is not installed on host OS, the speech system just fails to init.
Separate the speech system cpps into diferent files for each platform, copying the way it was done for mac, this is clearer and will make it easier to add other platforms, like android in the future.
Sanitize text was moved to an earlier stage, to fsspeech.cpp, to avoid having to repeat this bit of code in every implementation.
Note:
I may have broken mac tts with these changes and i have no way to test it.