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?
                        
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.
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), ]