Ren'Py How-to: Have a "self-voicing" ready game

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,124
14,802
Ren'Py have that marvelous feature that permit to automatically voice any game.

Of course, for the majority of us, it's relatively useless. It don't strictly voice the dialogs, but read the text currently visible in the screen.
But it's precisely what make it useful for all users who are vision impaired. They can still see well enough to enjoy the visual part of your game, but struggle to reading the dialog and narration.
And, of course, there's those who suffer from dyslexia and face too small letters for the dialogs, even when you use an easily readable font.
Despite its limitations, the Self-Voicing feature is a real plus for those persons, and you should take it in count when you make your game. After all, they are players like all the others, they deserve to be in position to enjoy your game.

The main issue is that it's a ready to go feature. It don't know what is part of the interface and what is part of the dialog. Like it don't know what part of the interface is mandatory, and what is not important. Therefore, most game are just not playable with self-voicing... Unless you, devs, care about this right and make them enjoyable. Something that can be done relatively easily and don't need much efforts.


Most of what you need to know is how to use the style property. Three letters that looks insignificant, but will change the life of everyone using Self-Voicing.

By default, the Self-voicing feature will say every text displayed on a screen, whatever it it's through the text, textbutton or label screen statements. And it will say this every single time a new dialog line, or narration line, is displayed. But, if the text have an alt property, then it's the content of that property that will be voiced, in place of the text displayed on the screen.

Let's say that you've an User Interface that display the day and time, Ren'Py will will voice all those information before it voice the dialog or narration line. And it will do it before every single dialog or narration lines.

Therefore, something like this:
Image1.jpg

Will be voice that way: "Day monday, time 12 AM, Unknow girl, Hey, do you want to be my boyfriend".
Then the next dialog line will come, with the MC answering "yes", and this time it's "Day monday, time 12 AM, MC, yes I want".

Annoying, isn't it ?

It's where the alt style property take all it's sense and meaning.
The code for my example screen is basic:
Python:
screen whatever():
    vbox:
        text "Day  [day]"
        text "Time: [time]"
And it suffice of a little nothing to turn it compliant with self-voicing:
Python:
screen whatever():
    vbox:
        text "Day  [day]":
            alt ""
        text "Time: [time]"
            alt ""
Now, the text displayed by the screen become silent, and the player will hear "Unknow girl, Hey, do you want to be my boyfriend", followed by "MC yes I want".


Just this is a great improvement, but you can, and should, go further.
"Unknow girl, Hey, do you want to be my boyfriend", it don't really sound good, right ? Something like "Unknow girl is saying: Hey, do you want to be my boyfriend" would be better. And, it happen that you can also do this, and without need for much effort. You only need to make two really small changes.

Firstly, tweak a bit the "namebox" style. It's the style used to display the name of the character saying the dialog line. Just add this anywhere in your code:
Python:
style namebox:
    alt ""
Now the name of the character will not be voiced anymore... What don't looks like an improvement, I know. But the magic come from the second change.

Open the file "screen.rpy" and look at the screen named "say". It's the one that display the dialogs.
Inside you'll fine that like: text what id "what"
Change it in this:
Python:
        text what:
            id "what"
            alt "{} is saying: {}".format( who, what )
And it's done, now when the self-voicing is enabled, Ren'Py will not anymore say "Unknow girl, Hey, do you want to be my boyfriend", but the "Unknow girl is saying: Hey, do you want to be my boyfriend" that is more natural.


All this is already great, the self-voicing isn't anymore polluted by useless text, and the dialog lines are voiced in a more natural way.
But there's still an issue, right ? If you made an User Interface displaying the day and time, it's because they are information that the player need to know... And now they aren't voiced anymore.

Don't worry, there's an alternative for this too, the character.
It's a special character, that exist by default and, like for narrator have no name. But this character is really special, because it will only be used if the self-voicing is enabled. So, all you have to do is to use it in order to voice the most important changes in the game.

Let's say that you use a basic day system:
Python:
# The string that will be displayed by your User Interface.
define dayToString = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]

label changeDay:
    $ day += 1   # One more day.
    $ day %= 7  # cycle between 0 and 6.
    return   # return to the game flow.
To make this self-voicing compliant, you just need a small change:
Python:
define dayToString = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]

label changeDay:
    $ day += 1
    $ day %= 7
    $ dayAsString = dayToString[day] # Get the day as text.
    alt "A new day starts, it's now [dayAsString]."  # Display the day as text *only* if self-voicing is enabled.
    return
For players who don't use the self-voicing, nothing will change. But for those who use it, they'll see, and more importantly hear, "A new day starts, it's now Thuesday", or whatever the day will effectively be.

If your code to handle the day is done purely in Python, you just have to use the function: renpy.say( alt, "Text to display and voice if the self-voicing feature is enabled." )

And the same should be done for the time of the day, for the money spent or earned, as well as for the points earned, or lost. Every value that is shown by your User Interface should be handled that way, with an alt narration line warning the player using self-voicing about the change.


There's more that could be said in regard of compliance for players suffering from an impaired vision, but on that How To I wanted to focus on the most important part, the self-voicing. And, regarding it, you now know everything there's to know, what mean that you don't anymore have an excuse to release games that aren't compatible with that feature.