Speech synthesis for Ren'py?

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
DaBackpack
Newbie
Posts: 8
Joined: Tue Mar 29, 2016 10:25 pm
Tumblr: dabackpack
Github: dabackpack
Skype: dabackpack
Contact:

Speech synthesis for Ren'py?

#1 Post by DaBackpack »

Hi all,

I'm trying to create voice files for a game I'm making and have turned to text-to-speech/speech synthesis options. Specifically, I'm dynamically creating voice lines "on the fly" and don't want to pre-compute all combinations allowed.

I've tried thus far to use gtts and pyttsx but have had trouble getting the dependencies working. ("No module named win32api", "No module named cgi")

I've read:
https://www.renpy.org/doc/html/self_voicing.html
and was wondering if this functionality is exposed to developers, i.e, can I use speech synthesis in my code without installing other modules? Otherwise, has anybody had success using gtts or pyttsx?


Thanks,

dab

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Speech synthesis for Ren'py?

#2 Post by Imperf3kt »

No idea what gtts or pyttsx are, but you know you don't need to install or modify anything at all, right? Literally all you need to do, is press "v" while running your game. This is persistent, and will be remembered the next time you run the game.

Unless you were saying you dislike the included voice?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
DaBackpack
Newbie
Posts: 8
Joined: Tue Mar 29, 2016 10:25 pm
Tumblr: dabackpack
Github: dabackpack
Skype: dabackpack
Contact:

Re: Speech synthesis for Ren'py?

#3 Post by DaBackpack »

Imperf3kt wrote:No idea what gtts or pyttsx are, but you know you don't need to install or modify anything at all, right? Literally all you need to do, is press "v" while running your game. This is persistent, and will be remembered the next time you run the game.

Unless you were saying you dislike the included voice?
Thanks for your response!

I understand that this is how you turn on self-voicing mode, but there are a few reasons why I don't want this:

1) This places a burden on the user to turn it on manually, whereas I want the voice functionality regardless (even if I turn it on by default, it becomes an option for the user, and they may unintentionally toggle the option without realizing it)
2) From a design standpoint, I don't want this to rely on self-voicing since character voicing is a core mechanic of the game --- if I ultimately do want to include accessibility options, I want "self-voicing mode" separate from the core mechanics of the game
3) There are features of self-voicing mode that I don't necessarily want turned on in the core version of the game --- focusable displayables, for example.

I'm willing to default to this solution, but ideally I want something that doesn't rely on a user-activated game mode.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Speech synthesis for Ren'py?

#4 Post by Imperf3kt »

I'm pretty sure there was a way to make sure focusable displays don't get voiced.
I can't say how, as I did this weeks ago, but I was reading the documentation when I discovered how.
There's also some stuff about the self voicing in the game files, though I cannot remember where.

Hope that helps a little.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
DaBackpack
Newbie
Posts: 8
Joined: Tue Mar 29, 2016 10:25 pm
Tumblr: dabackpack
Github: dabackpack
Skype: dabackpack
Contact:

Re: Speech synthesis for Ren'py?

#5 Post by DaBackpack »

Thanks for your response! I looked through the Ren'py source code and figured out what I wanted to do:

Code: Select all

    $import functools
    $say = functools.partial(renpy.display.tts.speak, force=True)
        
    $say("Hello!")
    p "Hello!" 
^ which always speaks the parameter ("Hello!") in text-to-speech fashion, regardless if Self-Voicing mode is on.

Just in case anybody else has the same problem!

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Speech synthesis for Ren'py?

#6 Post by PyTom »

Note that this is using an unsupported API that I could break at any moment.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Andredron, Ocelot, Semrush [Bot]