How to make typing sound in Renpy?

283 views Asked by At

I'm making an Ace Attorney fangame with RenPy. I want to play a "typing" sound when a character is talking.

I tried using this code:

define sounds = ['audio/sounds/bip1.mp3','audio/sounds/bip2.mp3','audio/sounds/bip3.mp3']
 
init python:
   def type_sound(event, interact=True, **kwargs):
   if not interact:
      return
 
   if event == "show":
 
      for i in range (50):
         renpy.sound.queue(renpy.random.choice(sounds))
 
   elif event == "slow_done" or event == "end":
       renpy.sound.stop()

I already have the sounds mentioned in the sounds list.

The problem is that the sounds get played continuously even if there is a pause in the dialogue. For example, in another script, a character says "My name is Walter, Walter Romanng", and I made a pause between the comma and the rest of the sentence; the sound still plays during the pause.

How can I make the typing sounds match the pace and timing of the text on screen?

2

There are 2 answers

1
Prince Abhay On

1.Prepare Typing Sound: First, make sure you have an audio file (e.g., a .wav or .mp3 file) for the typing sound that you want to use. Save it in your game's audio folder.

  1. Define a Function for Typing Sound: Create a function that plays the typing sound. You can place this function in your script or define it in the script.rpy file.

    script.rpy

    define sound_typing = [ ("audio/typing_sound.wav", 0.5), ]

0
BOB MIREILLARD On

Okay I found what was the problem, when I wanted tu make a "pause", I was using the {cps =1} tag but I find the right way to pause the dialogue:

"My name is Walter,{w=1} Walter Romanng"

this tag wait 1 second and then continue the dialogue, and it's not ignored by the type_sounds function.