Issue with play voice and queue voice with translation

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
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Issue with play voice and queue voice with translation

#1 Post by ComputerArt.Club »

Hi all,

I am trying to fix a bug in a translation of a game, it is a label that is called to frequently that plays a voice file.
Unfortunately, when the voiced part is just coded as:

Code: Select all

voice "filename.ogg"
It shows up in the translation file but it doesn't play for either the original or the translated game.

When it is code as

Code: Select all

queue voice "filename.ogg"
It plays the file in the original, but it isn't being included in the generated translation file.

When I code it as:

Code: Select all

play voice "filename.ogg"
I have the same issue. It plays in the original, but it isn't being included in the translation file.

Right before the screen is called there is a sound effect on the sound channel. So that could some how be interfering with the first example, though I am not sure why play voice is successful when voice is not.

As this is a screen, there is no accompanying written "speech" for this line so I don't know how to get the line identifier code to try to direct Renpy to this by myself (it doesn't get exported in the extract dialog operation, as it is not dialog).

All the other voice files are playing just fine, even ones with no text that call up screens. I guess the difference here is the sound file being played right before the voice file.
The sound file is being called like this:

Code: Select all

play sound "sfx.mp3"
call win
win is the label with the relevant voice file.

Any suggestions?
Thanks for your help.
Last edited by ComputerArt.Club on Mon Jun 03, 2019 12:14 pm, edited 1 time in total.

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: issue with play voice and queue voice with translation

#2 Post by ComputerArt.Club »

ugly ugly ugly workaround:
Main code:

Code: Select all

label win:
    queue voice "well done.ogg"
    voice "well done.ogg"
The second voice one doesn't get played in the English version for whatever reason started this whole problem (the preceding play sound file command perhaps?), but is translated and passed onto Japanese.

Translation code:

Code: Select all

# game/script.rpy:682
translate japanese win_1817be10:

    # voice "well done.ogg"
    play voice "jwelldone.ogg"
From there, play voice interrupts and stops the English one that was queued to play and so it plays the Japanese instead.
SO HORRIBLE. This feels very very broken and I anticipate problems further down the line.
Anyone got a more elegant solution?

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: Issue with play voice and queue voice with translation

#3 Post by ComputerArt.Club »

Something that would help address this same issue, there are also a few images that I would ideally change for translations because they are text based. Perhaps if I could get identifier codes for every line I would be able to replace those images/lines of code with:

Code: Select all

translate japanese labelname_IDCODE:
Is there a way to find the ID code for any particular line?

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Issue with play voice and queue voice with translation

#4 Post by philat »

Hmm. Might be a bug, honestly, but it seems to work fine if you add _() around the string: e.g., voice _("blahblah.ogg")

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Issue with play voice and queue voice with translation

#5 Post by Remix »

Code: Select all

show screen _auto_voice
(recent version of Ren'Py if possible)

Will give you the line identifier to dialogue only. Not sure how you would get one for a line that isn't dialogue as you'd need to hook it into the running code that happens while on that line.

You might also take a look at Ren'Py's auto_voice feature, which would allow you to automate all voice audio and allow you to gear the file names to include a translation folder or component...

Code: Select all

default auto_voice_file_string = "auto_voice/{language}/{identifier}.ogg"

init python:

    def get_auto_voice_file_name(identifier):

        # Amend the dict {language name : folder name} to suit 
        
        vdict = {
            'language' : {
                None : 'en', 
                'Spanish' : 'es',
                'Nihongo' : 'jp',
            }.get(_preferences.language, 'unknown'),
            'identifier' : identifier,
        }

        return auto_voice_file_string.format(**vdict)

    # Tell Ren'py to *try* to voice every line
    # using the above function to locate file
    config.auto_voice = get_auto_voice_file_name

label start:

    show screen _auto_voice

    "..." # This line is voiced if Ren'Py can find a file such as "auto_voice/en/start_a20cefa7.ogg" as shown in the screen
config.auto_voice can be a string, function or None ( https://renpy.org/doc/html/config.html# ... auto_voice )

If you do decide to go for auto_voice, I have a voice artist helper script that might be of use. Send me a PM if you want to try it (it basically reads the entire game and outputs all the lines and related filenames that each character should speak).
Frameworks & Scriptlets:

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: Issue with play voice and queue voice with translation

#6 Post by ComputerArt.Club »

philat wrote: Tue Jun 04, 2019 4:20 am Hmm. Might be a bug, honestly, but it seems to work fine if you add _() around the string: e.g., voice _("blahblah.ogg")
Thanks for your time and help and thanks for the tip about the _(), indeed I think I had issues with screens before when I didn't add brackets.
Right now the plain old voice tag is not playing for that instance, tried with brackets, I will try again with underscore soon, but for some reason it seems to want 'play' or 'queue' to play this voice file.
Remix wrote: Tue Jun 04, 2019 6:55 am

Code: Select all

show screen _auto_voice
(recent version of Ren'Py if possible)

Will give you the line identifier to dialogue only. Not sure how you would get one for a line that isn't dialogue as you'd need to hook it into the running code that happens while on that line.

You might also take a look at Ren'Py's auto_voice feature, which would allow you to automate all voice audio and allow you to gear the file names to include a translation folder or component...

Code: Select all

default auto_voice_file_string = "auto_voice/{language}/{identifier}.ogg"

init python:

    def get_auto_voice_file_name(identifier):

        # Amend the dict {language name : folder name} to suit 
        
        vdict = {
            'language' : {
                None : 'en', 
                'Spanish' : 'es',
                'Nihongo' : 'jp',
            }.get(_preferences.language, 'unknown'),
            'identifier' : identifier,
        }

        return auto_voice_file_string.format(**vdict)

    # Tell Ren'py to *try* to voice every line
    # using the above function to locate file
    config.auto_voice = get_auto_voice_file_name

label start:

    show screen _auto_voice

    "..." # This line is voiced if Ren'Py can find a file such as "auto_voice/en/start_a20cefa7.ogg" as shown in the screen
config.auto_voice can be a string, function or None ( https://renpy.org/doc/html/config.html# ... auto_voice )

If you do decide to go for auto_voice, I have a voice artist helper script that might be of use. Send me a PM if you want to try it (it basically reads the entire game and outputs all the lines and related filenames that each character should speak).
Thanks for your help Remix! This particular game is a remastered version of my first game with some extra langauges added, so I hadn't used auto voicing yet.
I used auto voice for one of my later games and I guess I wouldn't have known what to do when translating auto voice, so I will probably give that a go for a future game. Thanks again!

I'm still interested in finding a way to get the line identifier for any specific line (is it possible or do they only exist for dialog, text and voice?), like I mentioned earlier, sometimes there are images, especially images that contain text, that would be nice to change for translations. I wonder if this method could replace lines of random code like that.

User avatar
Matalla
Veteran
Posts: 202
Joined: Wed Mar 06, 2019 6:22 pm
Completed: Max Power and the Egyptian Beetle Case, The Candidate, The Last Hope, El cajón del viejo escritorio, Clementina y la luna roja, Caught in Orbit, Dirty Business Ep 0, Medianoche de nuevo, The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: Issue with play voice and queue voice with translation

#7 Post by Matalla »

For "translated" images, you don't need any identifier, just drop them in the tl/whatever_language/original_path/ with the same filename and renpy will show them

So, for example, if you have the image "bg_neon_sign.jpg" in your images folder, and you want to show an alternate one for, say, a spanish translation, put "bg_neon_sign.jpg" with the alternative content in tl/spanish/images/ and you're done
Comunidad Ren'Py en español (Discord)
Honest Critique

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Issue with play voice and queue voice with translation

#8 Post by Remix »

I didn't fully read your initial question...

All your syntax seems to indicate labels, yet you say you are using screens which call labels... Not too sure what you are after, though might advise an approach like:

Code: Select all

screen voice_test():
    text "Here"

    on "show":
        action PlayCharacterVoice( "eileen", _("arg.ogg") )
to add a character voice to a screen (using on "show" and action to avoid possible side effects)
This *should* translate fine
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot], Ocelot