Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-voicing doesn't apply custom text tags #3313

Closed
PhanesDionysos opened this issue Mar 2, 2022 · 0 comments
Closed

Self-voicing doesn't apply custom text tags #3313

PhanesDionysos opened this issue Mar 2, 2022 · 0 comments

Comments

@PhanesDionysos
Copy link

PhanesDionysos commented Mar 2, 2022

Issue

I've implemented a custom text tag that selects random choices from lists of options within the text, allowing for some generative/procedural text lines. Unfortunately, when self-voicing (TTS) is on, the tag doesn't actually seem to get applied for the purposes of the voice, resulting in every option being read out in sequence.

Self-voicing seems to use the original text of a Text object instead of the tokenized version that's had custom text tags applied. This is a problem when the custom text tag modifies the text itself instead of just styling it, as is the case with two of the examples in the docs: https://www.renpy.org/doc/html/custom_text_tags.html

Reproduction Steps

  1. Use either the rot13 or bang examples from: https://www.renpy.org/doc/html/custom_text_tags.html
  2. Hit "A" to open the accessibility menu and select Self-Voicing: "Debug"
  3. Hover over the produced dialogue and note that the text being voiced does not match the text being displayed.

Proposed Solution

Ideally, the custom tags would only be applied once, and the results of that application used for both visual display and self-voicing. This is useful for if there is any randomness in the custom tag logic or similar complex cases.

Workaround

As a workaround, I'm currently using the following monkeypatch, which is obviously not ideal:

def monkey_tts_decorator(method):
    def monkey_tts(self):
        real_text = self.text

        fake_text = ""

        for t_type, t_text in self.tokens:
            if t_type == renpy.text.textsupport.TEXT:
                fake_text += t_text
            elif t_type == renpy.text.textsupport.TAG:
                fake_text += "{" + t_text + "}"
            elif t_text == renpy.text.textsupport.PARAGRAPH:
                fake_text += "\n"

        self.text = [fake_text]

        ret = method(self)

        self.text = real_text

        return ret
    return monkey_tts

renpy.text.text.Text._tts = monkey_tts_decorator(renpy.text.text.Text._tts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants