Automatic Voice for two languages?

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
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Automatic Voice for two languages?

#1 Post by Kia »

How can I set config.auto_voice = "voice/{id}.ogg" for two or more set of voices in multiple languages?

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: Automatic Voice for two languages?

#2 Post by Remix »

Like images etc, it should work by copying the ./voice/ ogg files into a ./tl/language/voice/ folder... If it finds the right name there it should use that...

Alternatively

config.auto_voice = "voice/{language}/{id}.ogg"

might work... (do a "show screen _auto_voice" to test what file it is looking for)

I suggest though setting it to a function instead of just a string and adding some logic inside that function (using _preferences.language to get current along with the passed in identifier... compile a filename from those and return it)
Frameworks & Scriptlets:

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Automatic Voice for two languages?

#3 Post by Kia »

I did try config.auto_voice = "voice/{language}/{id}.ogg" and got:

Code: Select all

While running game code:
  File "game/script.rpy", line 29, in script
    e "You've created a new Ren'Py game."
  File "renpy/common/00voice.rpy", line 437, in voice_interact
    vi = VoiceInfo()
  File "renpy/common/00voice.rpy", line 330, in __init__
    fn = config.auto_voice.format(id=tlid)
KeyError: u'language'
putting the files into a voice folder inside the translation folder didn't work either.

peeking inside 00voice.rpy I can see there is a tlid variable but I cant find out how it is mixed into the file name, is it added to the end of the file name?
There should be tons of projects that have multiple voice sets and since I can't find anything about it in the documents or this forum, I assume it's something that renpy handles automatically and I've missed it or auto voicing is a relatively new feature

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: Automatic Voice for two languages?

#4 Post by Remix »

tlid is basically just the {id} and I guess stands for TransLation IDentifier or somesuch.

Best bet then is to write a function to do your thing...

Code: Select all

init python:

    def get_auto_voice_file_name(id): ### id is passed in automatically

        ## normal filename
        filename = "voice/{id}.ogg".format(id=id)

        if _preferences.language:
 
            ## Using non None language, so try it with "tl/language_folder" at the start
            language_filename = "tl/{language}/{filename}".format(
                language = _preferences.language,
                filename = filename)

                if renpy.loadable(language_filename ):

                    return language_filename 

        return filename

    config.auto_voice = get_auto_voice_file_name
Fly-typed (so might have minor errors)

That should look in the relative tl folder for files and use those if they exist (otherwise default to using normal file)
Tweak it if you do not want it dropping back to use the normal files if translated ones not found.

It should still be checkable with screen _auto_voice
Frameworks & Scriptlets:

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Automatic Voice for two languages?

#5 Post by Kia »

Thank you Remix, I'll try out you idea soon.
Let's hope it's addressed in the future updates as an easy solution.

Post Reply

Who is online

Users browsing this forum: konimyun