riperiperi / FreeSO

Re-implementation of The Sims Online.
http://freeso.org
Mozilla Public License 2.0
803 stars 95 forks source link

Possible TTS implementation on macOS systems #271

Open inb40 opened 1 year ago

inb40 commented 1 year ago

In this PR, I've made an implementation for TTS on macOS systems. This has been implemented with a new class named MacTTSContext, which extends the ITTSContext interface.

It runs the say (https://ss64.com/osx/say.html) command available on macOS systems, passing in arguments to customize and support most features the Windows implementation has. It runs each TTS execution in a new process (inefficient, but haven't found any other way), so it does not block the game while processing. There has been no noticeable latency in my testing.

I think this implementation is the next best thing to using the native speech synthesizer API on macOS, which can't be used (AFAIK) in the project unless you create a build for macOS.

Key points of the implementation:

Tested on macOS Monterey.

Preview of both voices in the game

Male voice (Alex): https://streamable.com/2gfkbt Female voice (Samantha): https://streamable.com/nzf9x5 Testing at a lot (most action I've been able to get): https://streamable.com/3gin92

Please let me know if there are any areas you want me to focus on for further refining or if you have any questions about the implementation. Thanks @riperiperi!!