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

Text to Speech #154

Open
Splendide-Imaginarius opened this issue Jan 17, 2024 · 2 comments
Open

Text to Speech #154

Splendide-Imaginarius opened this issue Jan 17, 2024 · 2 comments

Comments

@Splendide-Imaginarius
Copy link

Splendide-Imaginarius commented Jan 17, 2024

It might be interesting to support TTS in mkxp-z. Not sure what the implementation would look like, but Ren'Py has TTS, so maybe we could crib ideas from them.

(h/t @enumag and @Eblo)

@enumag
Copy link

enumag commented Jan 17, 2024

I was trying to use FFI to call NVDA and have it read the text shown in game. After throwing ideas back and forth with @Splendide-Imaginarius I eventually managed to find a working solution:

$tts = Win32API.new("nvdaControllerClient64.dll", "nvdaController_speakText", "p", "v")

def tts(text)
  $tts.call(text.encode('utf-16le'))
end

Adjustments might be needed to use on platforms other than windows since the encoding would likely need to be different than utf-16le on other platforms. But it's enough for my needs. Big thanks for helping me out with this!

(You can consider this code snippet licensed under WTFPL.)

@enumag
Copy link

enumag commented Mar 20, 2024

I recently made an improvement to this. There is a library called Tolk which is like an abstraction layer which can support multiple readers. I ended up using this fork which is more actively maintained. With this we're able to support more screen readers than just NVDA.

Win32API.new("libTolk.dll", "Tolk_Load", "", "v").call()
$tts = Win32API.new("libTolk.dll", "Tolk_Output", "p", "v")

def tts(text)
  $tts.call(text.encode('utf-16le'))
end

There is also an alternative library called UniversalSpeech. I didn't try it but it should work pretty much identically, just with different API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants