[Solved] How to sync Lip-Flap with Voiced Dialogue?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Hojoo
Newbie
Posts: 20
Joined: Wed Sep 28, 2022 7:26 pm
Contact:

[Solved] How to sync Lip-Flap with Voiced Dialogue?

#1 Post by Hojoo »

I'm stuck on getting lip-flap to stop when my character stops speaking!

Right now when my character speaks, the voice loop (a repeated 1 second clip) stops as soon as the dialogue text runs out; but for some reason, the lip-flap keeps going silently until a new character is speaking, even when the text and voice loop are done.

This is my callback function:

Code: Select all

init python:
    def main_callback(event, interact=True, **kwargs):
        if not interact:
            return
        if event == "show_done":
            renpy.sound.play("audio/toriel.mp3", loop="True", channel="sound")
            renpy.show("Vagabond mouth_talking")
        elif event == "slow_done" or event == "end":
            renpy.sound.stop(channel="sound")
            renpy.show("Vagabond mouth_neutral")
This is my character:

Code: Select all

init:
    define main = Character("[forname]", image="Vagabond", callback=main_callback)
These are some of my images, including the relevant part of a layeredimage:

Code: Select all

image VagabondTalking:
    "cc_mouth"
    pause .2
    "cc_mouth_open"
    pause .2
    repeat
layeredimage Vagabond:
    always:
        "cc_base"
    group mouth:
        attribute mouth_neutral default:
            "cc_mouth"
        attribute mouth_talking:
            "VagabondTalking"
        attribute mouth_open:
            "cc_mouth_open"
Does anyone know why the lip-flap and audio don't sync up? I've been looking through the old Ren'Py cookbook on blink and lip-flap which seems to get it to sync, but I can't figure out how to get it to work with layeredimage. Any help would be super duper appreciated!
Last edited by Hojoo on Sat Dec 31, 2022 6:19 pm, edited 1 time in total.

Hojoo
Newbie
Posts: 20
Joined: Wed Sep 28, 2022 7:26 pm
Contact:

Re: How to sync Lip-Flap with Voiced Dialogue?

#2 Post by Hojoo »

Figured it out! Adding the line renpy.restart_interaction() under the callback function ends the lip-flap as soon as the text stops scrolling.

Code: Select all

init python:
    def main_callback(event, interact=True, **kwargs):
        if not interact:
            return
        if event == "show_done":
            renpy.sound.play("audio/toriel.mp3", loop="True", channel="sound")
            renpy.show("Vagabond mouth_talking")
        elif event == "slow_done" or event == "end":
            renpy.sound.stop(channel="sound")
            renpy.show("Vagabond mouth_neutral")
            renpy.restart_interaction()

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot]