Table Of Contents

Previous topic

In-Game Menus

Next topic

Text

Search

Created using Sphinx.

Voice

Ren'Py includes support for playing back voice in conjunction with dialogue. This is done through the voice statement, which gives the voice filename to play:

voice "line0001.ogg"
"Welcome to Ren'Py"

Normally, a playing voice is stopped at the start of the next interaction. The voice sustain statement can sustain voice playback through an interaction.

voice "line0001.ogg"
"Welcome to Ren'Py..."

voice sustain
"... your digital storytelling engine."

The config.voice_filename_format variable allows you to customize the voice filename, making it possible to omit directories and extensions.

Voice Tags

Ren'Py includes a voice tag system that makes it possible to selectively mute or unmute a character's voice. To take advantage of this system, supply a voice_tag argument to each Character(), and use the SetVoiceMute() or ToggleVoiceMute() actions to allow the player to toggle the voice.

For example:

define e = Character("Eileen", voice_tag="eileen")
define l = Character("Lucy", voice_tag="lucy")

screen voice_toggle:
    vbox:
        textbutton "Mute Eileen" action ToggleVoiceMute("eileen")
        textbutton "Mute Lucy" action ToggleVoiceMute("lucy")

label start:
    show screen voice_toggle

    voice "e01.ogg"
    e "You can turn a character's voice on and off."

    voice "l01.ogg"
    l "Yeah! Now I can finally shut you up!"

    voice "l02.ogg"
    l "Wait... that means they can mute me as well! Really?"

Voice Functions

voice(filename, tag=None)

Plays filename on the voice channel. The equivalent of the voice statement.

filename
The filename to play. This is used with config.voice_filename_format to produce the filename that will be played.
tag

If this is not None, it should be a string giving a voice tag to be played. If None, this takes its default value from the voice_tag of the Character that causes the next interaction.

The voice tag is used to specify which character is speaking, to allow a user to mute or unmute the voices of particular characters.

voice_can_replay()

Returns true if it's possible to replay the current voice.

voice_replay()

Replays the current voice, if possible.

voice_sustain(ignored='', **kwargs)

The equivalent of the voice sustain statement.

Voice Actions

SetVoiceMute(voice_tag, mute)

If mute is true, mutes voices that are played with the given voice_tag. If mute is false, unmutes voices that are played with voice_tag.

ToggleVoiceMute(voice_tag, invert=False)

Toggles the muting of voice_tag. This is selected if the given voice tag is muted, unless invert is true, in which case it's selected if the voice is unmuted.

VoiceReplay()

Replays the most recently played voice.