Change How Self-Voicing Pronounces Words?
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.
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.
Change How Self-Voicing Pronounces Words?
Is it possible to change how self-voicing pronounces a word? There are names in my script that self-voicing can't handle, but I think if I could just change what self-voicing is trying to read, it would fix it.
For example:
Is there some way to set self-voicing to consistently read "hermione" as "hermy one" every time the name comes up?
I think this might be possible through the "alternative text" function, but honestly I'm a bit confused as to how it works.
Thanks!
For example:
Is there some way to set self-voicing to consistently read "hermione" as "hermy one" every time the name comes up?
I think this might be possible through the "alternative text" function, but honestly I'm a bit confused as to how it works.
Thanks!
- 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: Change How Self-Voicing Pronounces Words?
It is not an easy one to do afaik as there does not seem to be a function or map that does it all automatically based on words in the dialogue.
If anyone does want to explore further, you eventually want to change the what_alt of the line, e.g:
"Hermione" (what_alt="A different spoken line")
If anyone does want to explore further, you eventually want to change the what_alt of the line, e.g:
"Hermione" (what_alt="A different spoken line")
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Change How Self-Voicing Pronounces Words?
Self-voicing is not a replacement for voiced dialogue. It is merely a tool for visually impaired to be able to access your game at all. In fact RenPy does not voice anything. It is merely accesses speech synthesis API of OS it is running on, so any changes you want to make should be done on end-user OS. Which is not feasible.
< < insert Rick Cook quote here > >
- 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: Change How Self-Voicing Pronounces Words?
A rather *hacky* kludge:
Note: The mapping function simply does string replace if it finds the key with a space before or after... tweak/improve as wanted
Code: Select all
init -1 python:
voice_map = {
'hermione' : 'Emma Watson',
'harry' : 'Daniel Rad cliff',
}
def voice_substitute(*args, **kwargs):
what_alt = str(args[1]).lower()
for k in voice_map:
what_alt = what_alt.replace(
"{0} ".format(k),
"{0} ".format(voice_map[k])).replace(
" {0}".format(k),
" {0}".format(voice_map[k]))
if what_alt != str(args[1]).lower():
# substituted
kwargs.get('what_args', {}).update({'alt':what_alt})
return renpy.show_display_say(*args, **kwargs)
# this character has her dialogue (the 'what' part) altered on the fly
define h = Character("Hermione", show_function=voice_substitute)
label start:
# shows these words
# and yet autovoice says "Daniel Radcliffe fancies Emma Watson"
h "Harry fancies Hermione"
return
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Re: Change How Self-Voicing Pronounces Words?
Remix, thanks for your work!
The code you provided does change how self-voicing pronounces words, but for whatever reason, once it's activated, lines that don't contain any terms that need to be changed are no longer voiced.
So, for example:
Furthermore, if I then restart the game, Hermione's first line ("Test line") is voiced as "I am Daniel Radcliffe."
My game is pretty short (and I have very little coding experience), so I might just do the what_alts by hand, but if you come up with a solution for the above issue I'd love to see it.
The code you provided does change how self-voicing pronounces words, but for whatever reason, once it's activated, lines that don't contain any terms that need to be changed are no longer voiced.
So, for example:
Code: Select all
label start:
#self-voicing works normally
h "Test line."
#self-voicing reads: "Daniel Radcliffe fancies Emma Watson"
h "Harry fancies Hermione."
#self-voicing says nothing
h "Nobody fancies anyone."
#self-voicing says "I am Daniel Radcliffe"
h "I am Harry."
return
My game is pretty short (and I have very little coding experience), so I might just do the what_alts by hand, but if you come up with a solution for the above issue I'd love to see it.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Change How Self-Voicing Pronounces Words?
I seem to recall I just did something like this once: (Cannot test if it works as I remember from here.)
It works fine with screens, but I haven't tried it with say statements yet... That I recall. I think I actually did.
Code: Select all
define dumbledore = "Dumbledore" alt "dumb bell door"
label start:
harry "Professor [dumbledore]."
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
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: Change How Self-Voicing Pronounces Words?
Unfortunately this is not valid syntax. I tried:Imperf3kt wrote: ↑Sun Mar 25, 2018 10:18 pm I seem to recall I just did something like this once: (Cannot test if it works as I remember from here.)It works fine with screens, but I haven't tried it with say statements yet... That I recall. I think I actually did.Code: Select all
define dumbledore = "Dumbledore" alt "dumb bell door" label start: harry "Professor [dumbledore]."
Code: Select all
define dumbledore = "Dumbledore" (what_alt="dumb bell door")
label start:
harry "Professor [dumbledore]."
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 1, in script
define dumbledore = "Dumbledore" (what_alt="dumb bell door")
File "game/script.rpy", line 1, in <module>
define dumbledore = "Dumbledore" (what_alt="dumb bell door")
TypeError: 'unicode' object is not callable
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 1, in script
define dumbledore = "Dumbledore" (what_alt="dumb bell door")
File "C:\Users\Armin\Desktop\OneDrive - The University of Western Ontario\renpy-6.99.13-sdk\renpy\ast.py", line 1912, in execute
value = renpy.python.py_eval_bytecode(self.code.bytecode)
File "C:\Users\Armin\Desktop\OneDrive - The University of Western Ontario\renpy-6.99.13-sdk\renpy\python.py", line 1828, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/script.rpy", line 1, in <module>
define dumbledore = "Dumbledore" (what_alt="dumb bell door")
TypeError: 'unicode' object is not callable
Windows-8-6.2.9200
Ren'Py 6.99.14.3135
TEST 1.0
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Change How Self-Voicing Pronounces Words?
Hmm, I don't know where I 'remembered' that from, but checking the project I was sure I used it in, I don't see it anywhere. Am I losing my mind
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
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- 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: Change How Self-Voicing Pronounces Words?
You might have used:
define dumbledore = Text( "Dumbledore", alt="dum ball door" )
or something similar.
Give me a while to test a few bits and I will try to find what works...
define dumbledore = Text( "Dumbledore", alt="dum ball door" )
or something similar.
Give me a while to test a few bits and I will try to find what works...
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
- 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: Change How Self-Voicing Pronounces Words?
Not getting anywhere with this, so just a quick fix for my remap function:
Code: Select all
def voice_substitute(*args, **kwargs):
what_alt = str(args[1]).lower()
for k in voice_map:
what_alt = what_alt.replace(
"{0} ".format(k),
"{0} ".format(voice_map[k])).replace(
" {0}".format(k),
" {0}".format(voice_map[k]))
kwargs.get('what_args', {}).update({'alt':what_alt})
return renpy.show_display_say(*args, **kwargs)
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Re: Change How Self-Voicing Pronounces Words?
Imperf3kt, I've "remembered" similar things in the past, no worries Maybe you wanted to use it but it turned out not to work?
Remix, thanks again, it works perfectly!
Is there a way to make it replace all text, or do I have to individually use the function with each character? Also, is it only possible to use this function with dialogue, or would it be possible to use with screens, etc.?
Remix, thanks again, it works perfectly!
Is there a way to make it replace all text, or do I have to individually use the function with each character? Also, is it only possible to use this function with dialogue, or would it be possible to use with screens, etc.?
Re: Change How Self-Voicing Pronounces Words?
the biggest problem here is, that it doesn't care about the name of the person speaking.
so if Hermione is speaking, it will read the name as Hermione, and then change it to Emma Watson when she says it.
so if Hermione is speaking, it will read the name as Hermione, and then change it to Emma Watson when she says it.
- PyTom
- Ren'Py Creator
- Posts: 16096
- 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: Change How Self-Voicing Pronounces Words?
Although I don't know when 7.4 will be released, I've added the {noalt} text tag to take care of this. In conjuction with the also unreleased {alt} tag, this would let you do:
Code: Select all
"{noalt}Dumbledore{/noalt}{alt}Dumb bell dore{/alt}"
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]