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

SSML tags are incorrectly ignored at end of sentence #32

Open
liaeh opened this issue Oct 24, 2022 · 0 comments
Open

SSML tags are incorrectly ignored at end of sentence #32

liaeh opened this issue Oct 24, 2022 · 0 comments

Comments

@liaeh
Copy link

liaeh commented Oct 24, 2022

There is a bug where SSML tags are ignored if they occur at the end of a sentence, e.g. for marks and breaks.
E.g. for <s>No mark<mark name="before-time"/></s>, the tag marks_after is expected after the word mark, but is left out.

Another point is that neither the marks_before nor pause_before_ms are ever used, just the after variants.

Example:

from gruut import sentences

ssml_text = """<?xml version="1.0"?>
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.w3.org/2001/10/synthesis
                   http://www.w3.org/TR/speech-synthesis/synthesis.xsd"
         xml:lang="en-US">
  <s>No mark<mark name="before-time"/></s>
  <s>Yes<mark name="before-time"/> mark</s>
  <s>No break <break time="1s"/></s> 
  <s>With <break time="1s"/> break</s> 
</speak>"""

for sent in sentences(ssml_text, ssml=True):
    for word in sent:
        if word.phonemes:
            x = {
                "sent_idx": word.sent_idx,
                "lang": word.lang,
                "orig": word.text,
                "phones": list(word.phonemes),
                "is_punct": word.is_punctuation,
            }
            extras = [
                "marks_before",
                "marks_after",
                "pause_before_ms",
                "pause_after_ms",
            ]
            for extra in extras:
                attr_value = word.__getattribute__(extra)
                if attr_value:
                    x[extra] = attr_value
        print(x)

Outputs:

{'sent_idx': 0, 'lang': 'en-US', 'orig': 'No', 'phones': ['n', 'ˈoʊ'], 'is_punct': False}
{'sent_idx': 0, 'lang': 'en-US', 'orig': 'mark', 'phones': ['m', 'ˈɑ', 'ɹ', 'k'], 'is_punct': False}  # mark missing
{'sent_idx': 1, 'lang': 'en-US', 'orig': 'Yes', 'phones': ['j', 'ˈɛ', 's'], 'is_punct': False, 'marks_after': ['before-time']}  # mark there
{'sent_idx': 1, 'lang': 'en-US', 'orig': 'mark', 'phones': ['m', 'ˈɑ', 'ɹ', 'k'], 'is_punct': False}
{'sent_idx': 2, 'lang': 'en-US', 'orig': 'No', 'phones': ['n', 'ˈoʊ'], 'is_punct': False}
{'sent_idx': 2, 'lang': 'en-US', 'orig': 'break', 'phones': ['b', 'ɹ', 'ˈeɪ', 'k'], 'is_punct': False}  # pause missing
{'sent_idx': 3, 'lang': 'en-US', 'orig': 'With', 'phones': ['w', 'ˈɪ', 'θ'], 'is_punct': False, 'pause_after_ms': 1000}  # pause there
{'sent_idx': 3, 'lang': 'en-US', 'orig': 'break', 'phones': ['b', 'ɹ', 'ˈeɪ', 'k'], 'is_punct': False}
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

1 participant