Page 1 of 1

How could I get the dialog spoken with my TTS?

Posted: 03 Jun 2018, 18:47
by simion314
Hi all, I have bad eyes so I am struggling when I have to read a lot of text, my main solutions are using zoom software or OCR the screen and have the TTS software read the dialogue.
My questions is can I make a mod that would detect the dialog and call the TTS software via command line or dbus?
If it can be done via a mod can you point me to instructions on how to do it
If is not possible with mods, can you point me to the right place in the source code where I can hack this in ?
I know how to code so I may be able to add this, again this is for accessibility reasons and I don't intend to have something high quality.
Thank you.

Re: How could I get the dialog spoken with my TTS?

Posted: 03 Jun 2018, 19:38
by Thunderforge
I'm all for making OpenMW more accessible to others, and TTS compatibility would be a great addition!

A traditional Morrowind ESM/ESP mod would not have the ability to add this sort of capability. But given that OpenMW is open-source, it would certainly be possible to submit a pull request for new code that adds this sort of capability.

You said that you know how to code. Have you added this sort of capability to other apps? What did you use to do that? If you haven't done it yourself, are you aware of any resources that others could use to learn more about adding TTS compatibility?

Re: How could I get the dialog spoken with my TTS?

Posted: 03 Jun 2018, 20:22
by simion314
About my experience with TTS, I had some contributions to a Jovie a KDE application for Linux that is a wrapper for speech dispatcher.
Since I am running Linux/KDE (is a very accessible system for my particular problems) what I usually do is to connect existing command line applications like
1 use convert command line app to grab a screenshot
2 use other command line app to grayscale the image, and revert colors if needed (OCR is designed to work for black on white)
3 OCR the image to a text file
4 have jovie or other TTS app read the file
I put all this steps in a bash script , would probably work with python too

The above method has limitations like
1 the dialogue text must be always on the same section of screen, I need to grab the exact rectangle of text (the coordinates are hardcoded in the script for each game)
2 if the text background is transparent/has alpha then the OCR will get confused and will see text where is none
3 if the fonts are say to different then regular fonts the OCR gets confused again, so for some games I attempted to change the used fonts

I think that adding the ability to call the user TTS is the best solution because you can use your existing voices, in my case I use the ugly robotic voices but I have them on very high speed, usually people that use TTS for accessibility are using this high speeds.

So if I know where the dialog code is triggered, say when new dialog is appeneded in the dialog box , I would need to find a way to run the TTS app and pass it the text that was said, sure if we could send some NPC details you could have different voice configured and use a specific voice for that NPC, like a female voice for a female NPC.

Re: How could I get the dialog spoken with my TTS?

Posted: 04 Jun 2018, 09:30
by Zini
At least as a quick hack, the easiest option would be the GUI (apps/openmw/mwgui/dialogue.hpp). There is a addResponse method that should do the job.

Re: How could I get the dialog spoken with my TTS?

Posted: 04 Jun 2018, 11:56
by simion314
@Zini thanks

Edit
At least as a quick hack, the easiest option would be the GUI (apps/openmw/mwgui/dialogue.hpp). There is a addResponse method that should do the job.
I implemented this hack, seems to work fine in the quick test I done.
If there is a way I can contribute this in a non hacking way let me know, say maybe we can expose the dialogs to the mods, then a mod can be more easy configured to call a script

Re: How could I get the dialog spoken with my TTS?

Posted: 01 Apr 2020, 16:32
by Lokkje
Hi, I know this is an old thread, but in case you read this, could you share your solution please? I want to try to adapt it to the android version of the game.