Skip to content

[Bug]: ssml_to_deepgram leaves XML entities such as & and ' in the TTS text #811

Open

Description

@RaphaelFakhri

Summary

ssml_to_deepgram() and TextBuilder.from_ssml() do not decode XML entities, so escaped characters in valid SSML are sent to TTS as literal entity text.

What happened?

SSML is XML, so & must be written as &amp;, and apostrophes and quotes are often written as &apos;, &quot;, or &#39;. The converter strips tags but keeps the entities, in plain text and in the <phoneme> word and ph value. The resulting text contains AT&amp;T instead of AT&T.

Steps to reproduce

from deepgram.helpers import ssml_to_deepgram

print(ssml_to_deepgram("<speak>Call AT&amp;T, it&apos;s open.</speak>"))
# Call AT&amp;T, it&apos;s open.

print(ssml_to_deepgram('<phoneme alphabet="ipa" ph="t&#601;">AT&amp;T</phoneme>'))
# \{"word": "AT&amp;T", "pronounce": "t&#601;"\}

Expected: Call AT&T, it's open. and \{"word": "AT&T", "pronounce": "tə"\}.

Transport

N/A (helper, no network).

API endpoint / path

/v1/speak and /v2/speak text built with deepgram.helpers.

Is this a regression?

No. The behavior has existed since the helper was added.

SDK version

7.14.0 (main at 3ad56ae).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions