Skip to content

TTS Speech rework#7357

Open
Shivansps wants to merge 17 commits intoscp-fs2open:masterfrom
Shivansps:speech-rework
Open

TTS Speech rework#7357
Shivansps wants to merge 17 commits intoscp-fs2open:masterfrom
Shivansps:speech-rework

Conversation

@Shivansps
Copy link
Copy Markdown
Contributor

@Shivansps Shivansps commented Apr 7, 2026

The objectives of this pr are:

  1. Add TTS Speech options to ingame options settings. Incliding voice selection, voice rate, volume settings and select places were TTS is used

  2. 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.

  3. 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.

  4. 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.

@wookieejedi wookieejedi added enhancement A new feature or upgrade of an existing feature to add additional functionality. refactor A cleanup/restructure of a feature for speed, simplicity, and/or maintainability labels Apr 7, 2026
@Sessile-Nomad
Copy link
Copy Markdown

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 🙂

@Shivansps
Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor

@notimaginative notimaginative left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +10 to +11
static SCP_vector<SCP_string> cached_voices;
static bool voices_cached = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really doesn't need to happen. It's a complete waste of memory. The voices should be cached of course, but that should happen when and where it's needed, not globally at startup.

I'm only marking that issue here, but it applies to win and linux versions as well.

Comment on lines +134 to +135
// 180 wpm = normal
float rate = 180.0f * (rate_percent / 100.0f);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base speaking rate varies by the voice in use so you can't use a general default value and have it sound right. I recommend using something similar to the attached diff which gets the default voice rate when a voice is set and uses that as the value for these calculations.

speech-rework-rate.patch

This applies to the Mac voice stuff only, but the Linux and Windows versions may need something similar, along with the value cap for safety.

@MjnMixael
Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A new feature or upgrade of an existing feature to add additional functionality. refactor A cleanup/restructure of a feature for speed, simplicity, and/or maintainability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants