Making typing sounds compatible with automatic pauses

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
pickledylans
Newbie
Posts: 3
Joined: Sat Oct 22, 2022 9:00 pm
Contact:

Making typing sounds compatible with automatic pauses

#1 Post by pickledylans » Sat Oct 22, 2022 9:06 pm

Hi everyone! So theres two codes ive found that im using rn, one is to make sounds when the text comes up on screen (think pheonix wright) and one is to create automatic pauses when theres commas and periods.

The only problem is the sound continues during pauses, which creates a weird effect. Obviously something needs to change... but i dont know what to do. any help is appreciated :)

Code: Select all

# Text Sound system
init python:
    def A1Voice(event, interact=True, **kwargs):
        if not interact:
            return
        if event == "show_done":
            renpy.sound.play("audio/A1.ogg",loop=True)
        elif event == "slow_done":
            renpy.sound.stop()

Code: Select all

#Text Speed system
init python:

    def slow_punctuation(str_to_test):
        str_to_test = str_to_test
        return str_to_test.replace(
            ", ", ",{cps=3} {/cps}").replace(
            "... ", "...{cps=1.3} {/cps}").replace(
            ". ", ".{cps=2} {/cps}").replace(
            "! ", "!{cps=2} {/cps}").replace(
            "? ", "?{cps=2} {/cps}").replace(
            "St.{cps=2} {/cps}", "St. ").replace(
            "Mr.{cps=2} {/cps}", "Mr. ").replace(
            "Ms.{cps=2} {/cps}", "Ms. ").replace(
            "Mx.{cps=2} {/cps}", "Mx. ").replace(
            "Dr.{cps=2} {/cps}", "Dr. ")

    config.say_menu_text_filter = slow_punctuation

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Making typing sounds compatible with automatic pauses

#2 Post by Ocelot » Sun Oct 23, 2022 5:43 am

Why change of cps and not timed pause? I doubt you can call your callback just in the middle of the text without any pauses.
< < insert Rick Cook quote here > >

pickledylans
Newbie
Posts: 3
Joined: Sat Oct 22, 2022 9:00 pm
Contact:

Re: Making typing sounds compatible with automatic pauses

#3 Post by pickledylans » Sun Oct 23, 2022 11:58 am

Ocelot wrote:
Sun Oct 23, 2022 5:43 am
Why change of cps and not timed pause? I doubt you can call your callback just in the middle of the text without any pauses.
Its just the only method for a system that automatically pauses during commas and periods i could personally find. If theres a different way of doing it id love to hear it!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]