Skip to content

fix(voice): read an unbraced command exponent or subscript as one word - #3275

Open
XAE-A-Xii wants to merge 1 commit into
HKUDS:devfrom
XAE-A-Xii:fix/speech-unbraced-command-scripts
Open

XAE-A-Xii wants to merge 1 commit into
HKUDS:devfrom
XAE-A-Xii:fix/speech-unbraced-command-scripts

Conversation

@XAE-A-Xii

Copy link
Copy Markdown

Description

Read-aloud split a Greek letter (or any other mapped command) that's used as an unbraced exponent or subscript. _verbalize_math (deeptutor/services/voice/speech_text.py) runs _replace_named_commands before _verbalize_scripts, so $x^\pi$ became x^ pi . The script reader then skips the space and takes a single character:

$x^\pi$       -> ' x to the p i '
$x_\alpha$    -> ' x sub a lpha '
$e^\lambda t$ -> ' e to the l ambda t '
$x^\infty$    -> ' x to the i nfinity '
$a^\theta$    -> ' a transpose heta '      (the "t" hits the transpose rule)
$x^{\pi}$     -> ' x to the pi '           (braced form was already fine)

x^\pi and x_\alpha are common unbraced spellings in lecture notes and model output.

A mapped command that directly follows ^ or _ (optionally after whitespace) is now replaced inside braces, x^{pi}, which the script reader already handles. The results are "x to the pi", "x sub alpha", "e to the lambda t", "x to the infinity" and "a to the theta". Braced scripts, 90^\circ ("90 degrees") and A^\top ("A transpose") are unchanged.

Related Issues

  • None filed; this is a small, self-contained fix.

Module(s) Affected

  • agents
  • api
  • config
  • core
  • knowledge
  • logging
  • services
  • tools
  • utils
  • web (Frontend)
  • docs (Documentation)
  • scripts
  • tests
  • Other: ...

Checklist

  • This PR targets dev (not main — see the base-branch selector above).
  • I have read and followed the contribution guidelines.
  • My code follows the project's coding standards.
  • I have run pre-commit run --all-files and fixed any issues.
  • I have added relevant tests for my changes.
  • I have updated the documentation (if necessary). (Not needed.)
  • My changes do not introduce any new security vulnerabilities.

Additional Notes

tests/services/test_speech_unbraced_command_script.py is written in the same style as test_speech_transpose_superscript.py. It checks six unbraced cases (^\pi, _\alpha, ^\lambda t, ^\infty, ^\theta, ^ \beta), plus three guards that already passed: braced ^{\pi}, ^\circ and ^\top.

Before the fix: 6 failed, 3 passed. Mutations are caught too: dropping the optional whitespace fails 1 case, matching only ^ fails 2, and omitting the braces fails all 6.

$ python -m pytest <every test file that imports services.voice / speech_text / verbalize> -q
406 passed, 26 subtests passed

Three locale tests (tests/i18n/test_{hungarian,italian,turkish}_locale.py) can't be collected locally, because they need data/user/settings/main.yaml from a configured install. That's the same on dev. pre-commit run --files on both changed files passes every hook. --all-files fails mypy on dev itself in services/embedding/adapters/volcengine.py, from #1015, which this PR doesn't touch.

🤖 Generated with Claude Code

@github-actions github-actions Bot added backend Python runtime, capabilities, tools, API & CLI bug Something isn't working labels Dec 5, 2026
`_verbalize_math` replaces named commands (Greek letters, \infty, ...)
before it verbalizes scripts, so `$x^\pi$` became `x^ pi ` and the
script reader then took only the next character: speech said "x to the
p i", "x sub a lpha", "e to the l ambda t", and `$a^\theta$` even hit
the transpose rule ("a transpose heta"). Braced `x^{\pi}` was fine.

A mapped command that directly follows ^ or _ (optionally after
whitespace) is now replaced inside braces, so the script reader takes
the whole word: "x to the pi", "x sub alpha". Braced scripts, ^\circ
and ^\top are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XAE-A-Xii
XAE-A-Xii force-pushed the fix/speech-unbraced-command-scripts branch from 7121a6c to e3d882e Compare December 5, 2026 12:15

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

backend Python runtime, capabilities, tools, API & CLI bug Something isn't working

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant