Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/deepgram/helpers/text_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def ssml_to_deepgram(ssml_text: str) -> str:
speak_pattern = r"<speak[^>]*>(.*?)</speak>"
speak_match = re.search(speak_pattern, ssml_text, re.DOTALL)
if speak_match:
ssml_text = speak_match.group(1)
ssml_text = re.sub(speak_pattern, r"\1", ssml_text, flags=re.DOTALL)

# Process the SSML text
# Parse XML fragments manually to handle mixed content
Expand Down
7 changes: 7 additions & 0 deletions tests/custom/test_text_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ def test_speak_wrapper(self):
result = ssml_to_deepgram(ssml)

assert result == "Hello world"

def test_speak_wrapper_preserves_surrounding_text(self):
"""Text outside a <speak> wrapper must not be discarded."""
ssml = "Before <speak>Inside</speak> after"
result = ssml_to_deepgram(ssml)

assert result == "Before Inside after"

def test_complex_ssml_rejects_mixed_controls(self):
"""Flux batch cannot combine SSML phoneme and break controls."""
Expand Down