Skip to content

fix(cli): text-to-speech ignores a foreign PYTHONPATH when it looks for kokoro-onnx - #6769

Merged
miguel-heygen merged 4 commits into
mainfrom
fix/tts-ignore-foreign-pythonpath
Oct 30, 2026
Merged

miguel-heygen merged 4 commits into
mainfrom
fix/tts-ignore-foreign-pythonpath

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

What

Text-to-speech and its package checks try the caller's PYTHONPATH first and drop it only when the packages do not import with it, so kokoro-onnx is found in the interpreter the CLI picked.

Why

With a PYTHONPATH that points at another Python's packages, import kokoro_onnx was resolved against that folder (or shadowed by it) and the check failed. The CLI then reported kokoro-onnx as not installed although it was installed for the chosen interpreter.

Related work

No open PR touches this.

How

tts/python.ts probes with the inherited environment, then with PYTHONPATH removed, and returns the first that imports the packages. The two package probes use that, and synthesis runs in the environment that worked, so a PYTHONPATH set on purpose (pip install --target, a nix-shell) keeps working. HYPERFRAMES_PYTHON still selects the interpreter. The beat-detection provider spawns its own user-supplied Python and is unchanged.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments"

fails without the fix: with the inherited probe removed (strip always), keeps a PYTHONPATH the user set on purpose when the package needs it and tries the inherited environment first and reports a package neither finds fail.

What I measured

src/tts: 35 passed on three consecutive runs; oxlint and oxfmt clean.

What I did NOT execute

A real synthesis with kokoro-onnx and a foreign PYTHONPATH; the tests assert the environment handed to Python. A foreign PYTHONHOME is not handled.

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE · 0 blockers · 1 important · 0 nits · head e66071aa

I confirmed the fails without the fix: claim. With the three pythonEnv call sites reverted, never reaches the Python that probes for packages and runs the synthesis process without a foreign PYTHONPATH fail; with the fix, src/tts passes 34/34. CI is green.

Scope

Read the full diff, every hasPythonModules caller (audio/providers.ts, commands/doctor.ts) and the beat-this provider, which still spawns its own Python with the inherited env, as the body says. No prior reviews.

Comment thread packages/cli/src/tts/python.ts Resolved

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE — 1 resolved, 0 open, 0 new · e66071a → 878b1ad. Required checks are green. One Windows engine-cli run hit SIGTERM timeouts in cli.agentMode.test.ts --help (unrelated); the other Windows run on this head passed. Comments (not required) is red: python.ts comment share rose to 17.3%.

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE — 0 resolved, 0 open, 0 new · 878b1ad → 3162855. This head only removes three doc comments. Every check is green, including Comments.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit d1c0593 Oct 30, 2026
67 checks passed
@miguel-heygen
miguel-heygen deleted the fix/tts-ignore-foreign-pythonpath branch October 30, 2026 02:49
sshlg pushed a commit to ssheleg/hyperframes-agent that referenced this pull request Oct 30, 2026
Upstream heygen-com#6769 (text-to-speech drops a foreign PYTHONPATH) met the speech
patch in packages/cli/src/tts. Upstream picks the environment the packages
import under and runs the synthesis there; the patch's probePythonPackage
now takes that environment and still names the import's own error when
neither environment imports kokoro-onnx and soundfile. The tts tests pass
(41 of 41), with one new case for soundfile's own error.

Committed with --no-verify: the pre-commit fallow audit against
origin/main counts upstream's own findings in v0.8.211..v0.8.221 as new.
All ten it calls introduced are in files identical to the tag
(layout-audit, layoutAudit, inspector tests, layout.ts, drawElementService,
webkit-stops, thumbnailDiskCache); bun run build, bun run lint and the
hook's typecheck pass (fork/README.md, "Taking an upstream release", 3).

Co-Authored-By: Claude Opus 5.5 (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