Playback the displayed voice file again

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
User avatar
darlo
Regular
Posts: 94
Joined: Mon Aug 27, 2012 6:54 am
Completed: Outlandish Move
Organization: Unorganised
Location: Yamaguchi Prefecture
Contact:

Playback the displayed voice file again

#1 Post by darlo »

Hi folks,
Today's problem is audio related. I'm after a way for players to play back the voice file that has just been played so they can check if they heard it correctly (my game is language-learning oriented so a repeat-button would be ideal).

Over the weekend I tried playing around with screens but didn't get anywhere, and this morning I took a stab at adding a button to the default in-game menu. I can't work out though how to get it to play the last used file.
What I have at the moment will play a specific file, but it will play it over everytime the scene progresses.
Any help?
Thank you.

Code: Select all

##############################################################################
# Quick Menu
#
# A screen that's included by the default say screen, and adds quick access to
# several useful functions.
screen quick_menu:

    # Add an in-game quick menu.
    hbox:
        style_group "quick"
    
        xalign 1.0
        yalign 1.0

        textbutton _("Repeat") action voice("michelle/Michelle_247.ogg")#at the mo this just plays the line over and over
        textbutton _("Q.Save") action QuickSave()
        textbutton _("Q.Load") action QuickLoad()
        textbutton _("Save") action ShowMenu('save')
        textbutton _("Skip") action Skip()
        textbutton _("Auto") action Preference("auto-forward", "toggle")
        textbutton _("Prefs") action ShowMenu('preferences')

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: Playback the displayed voice file again

#2 Post by apricotorange »

See http://www.renpy.org/doc/html/voice.html#voice-actions ? You probably want something like:

Code: Select all

        textbutton _("Repeat") action VoiceReplay()

User avatar
darlo
Regular
Posts: 94
Joined: Mon Aug 27, 2012 6:54 am
Completed: Outlandish Move
Organization: Unorganised
Location: Yamaguchi Prefecture
Contact:

Re: Playback the displayed voice file again

#3 Post by darlo »

Edit: Just a mo, I've realised that VoiceReplay was a part of the 6.15 update. I'll just update first.

Thanks for the rapid reply, that seems to be what I'm after. I'm having a wee bit of a problem though. Could you tell me where (and how) I need to define it?

Code: Select all

While running game code:
  File "game\script.rpy", line 163, in script
  File "game\screens.rpy", line 58, in python
  File "game\screens.rpy", line 519, in python
NameError: name 'VoiceReplay' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\execution.py", line 266, in run
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\ast.py", line 401, in execute
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\exports.py", line 750, in say
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\character.py", line 770, in __call__
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\character.py", line 664, in do_display
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\character.py", line 450, in display_say
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\character.py", line 648, in do_show
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\character.py", line 263, in show_display_say
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\display\screen.py", line 565, in get_widget
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\display\screen.py", line 247, in update
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\screenlang.py", line 1193, in __call__
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\python.py", line 1172, in py_exec_bytecode
  File "game\screens.rpy", line 58, in <module>
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\display\screen.py", line 540, in use_screen
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\screenlang.py", line 1193, in __call__
  File "C:\Users\Darlo\Desktop\Renpy\renpy-6.14.1-sdk\renpy\python.py", line 1172, in py_exec_bytecode
  File "game\screens.rpy", line 519, in <module>
NameError: name 'VoiceReplay' is not defined

Windows-7-6.1.7601-SP1
Ren'Py 6.14.1.366
Outlandish Move 2.0 WIP

User avatar
darlo
Regular
Posts: 94
Joined: Mon Aug 27, 2012 6:54 am
Completed: Outlandish Move
Organization: Unorganised
Location: Yamaguchi Prefecture
Contact:

Re: Playback the displayed voice file again

#4 Post by darlo »

That is absolutely perfect!
I was worried that it would just play the last voice file regardless of where the player was (including the players words, which are non-voiced) but it doesn't. This really was exactly what I was after.
Thanks.

Post Reply

Who is online

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