Skip to content

fix: strip markdown markers and table pipes from text-to-speech - #31

Merged
iuhoay merged 1 commit into
mainfrom
fix/tts-strip-markdown
Jun 14, 2026
Merged

fix: strip markdown markers and table pipes from text-to-speech#31
iuhoay merged 1 commit into
mainfrom
fix/tts-strip-markdown

Conversation

@iuhoay

@iuhoay iuhoay commented Jun 14, 2026

Copy link
Copy Markdown
Owner

What & why

The Speak buttons passed raw model.output (and model.inputText) straight to AVSpeechSynthesizer, so it read markdown out loud literally — table pipes and the | --- | delimiter row, plus **, *, `, #, list bullets, and link URLs. Now that results commonly contain tables, this was noticeable.

How

  • Add ResultSegment.spokenText(_:) — a speech-friendly plain-text projection:
    • Tables reuse the existing parser, so the delimiter row is already gone; cells are read as comma-separated values, rows separated by a period.
    • Inline markers (**/__/*/`/~~) are removed; [text](url)/![alt](url) unwrap to their label.
    • Block prefixes (heading #, blockquote >, ordered/unordered list bullets) and thematic breaks (---) are stripped.
    • Plain text without markup is returned unchanged.
  • Both the Original and result Speak buttons route through it (TranslationView).

Testing

  • xcodebuild ... test green — 97 tests / 14 suites, including a new SpokenTextTests suite (7 tests): inline markers, link/image unwrap, block prefixes, thematic breaks, and tables (asserting no | or --- survive and cells join as expected).
  • TTS output is audio, so it can't be snapshotted; the projection is covered by unit tests.

Closes the TTS gap noted in #30.

🤖 Generated with Claude Code

The Speak buttons fed raw model.output to AVSpeechSynthesizer, so it vocalized
table pipes/delimiter rows and inline markers (**, *, `, #, -, links) literally.

Add ResultSegment.spokenText(_:) — a speech-friendly projection that reuses the
table parser (so the `| --- |` delimiter row is already dropped) to read table
cells as comma-separated values, and strips inline/block markdown markers from
the rest. Plain text without markup is returned unchanged. Both the input and
result Speak buttons now route through it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@iuhoay
iuhoay merged commit da79006 into main Jun 14, 2026
1 check passed
@iuhoay
iuhoay deleted the fix/tts-strip-markdown branch June 14, 2026 02:38
iuhoay added a commit that referenced this pull request Jun 15, 2026
Bump MARKETING_VERSION / CFBundleShortVersionString to 0.2.0 and move the
CHANGELOG [Unreleased] section into a dated [0.2.0] entry. Adds the
previously-unlisted auto-resize window feature (#34) and the TTS markdown
stripping fix (#31) to the notes.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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