Skip to content

fix(helpers): preserve text outside speak wrapper in ssml_to_deepgram - #834

Open
adityajai119 wants to merge 1 commit into
deepgram:mainfrom
adityajai119:fix/w80a
Open

adityajai119 wants to merge 1 commit into
deepgram:mainfrom
adityajai119:fix/w80a

Conversation

@adityajai119

Copy link
Copy Markdown

Bug

ssml_to_deepgram() unwrapped a <speak> element by assigning speak_match.group(1) to the whole input. Any text before or after the wrapper (including a second <speak> block) was silently discarded.

from deepgram.helpers import ssml_to_deepgram

ssml_to_deepgram("Before <speak>Inside</speak> after")
# before: "Inside"
# after:  "Before Inside after"

Fix

Replace each <speak>...</speak> span in place with its inner content instead of replacing the entire string with the first match.

Verification

  • pytest tests/custom/test_text_builder.py — 57 passed (new test failed before the fix: expected "Before Inside after", got "Inside")
  • ruff check src/deepgram/helpers/text_builder.py tests/custom/test_text_builder.py — passed

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant