Skip to content

fix(media): read ElevenLabs input as UTF-8 - #5469

Merged
jrusso1020 merged 3 commits into
heygen-com:mainfrom
Dante-dan:fix/5464-elevenlabs-utf8
Oct 12, 2026
Merged

jrusso1020 merged 3 commits into
heygen-com:mainfrom
Dante-dan:fix/5464-elevenlabs-utf8

Conversation

@Dante-dan

Copy link
Copy Markdown
Contributor

What

Read ElevenLabs text input explicitly as UTF-8.

Why

The JavaScript writer emits UTF-8. Python's default open() encoding can be cp1252 on Windows 11 with UTF-8 mode disabled, corrupting non-ASCII narration before it reaches ElevenLabs.

Related work

Fixes #5464 (the reported text-decoding defect). The related model-selection observation is outside this correction.

How

Set encoding="utf-8" on the inline Python helper's text-file read, matching the existing writer.

Test plan

  • Existing tts.test.mjs and tts.spawn.test.mjs: 23 tests passed using the repository test-home setup.
  • Changed-file oxlint and oxfmt checks passed.
  • Comment citations, comment ratchet, and git diff --check passed.
  • Windows 11/Python cp1252 reproduction and live ElevenLabs synthesis were not run locally; the fix follows the issue's reproduction and the current writer/reader code path.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at ca4dc947. Approving. Thanks for the fix!

This was the only file read that needed it. In ELEVENLABS_PY, open(sys.argv[1]) was the one Python read of the text file. Node writes that file with writeFileSync(p, text), which is UTF-8, so on Windows Python's default cp1252 decode garbled anything non-ASCII. Now that read says encoding="utf-8". I also checked the other places that hand text to a subprocess:

  • kokoro: hyperframes tts <file> reads the file in Node with "utf-8" and passes the text to Python in argv. Windows hands that to Python as Unicode, so no locale decode happens.
  • lyria and musicgen (bgm.mjs): the prompt goes in argv or inside the -c source, with no file read. gemini-auth.py already opens its file with encoding="utf-8" and reconfigures its streams. gemini-tts.mjs doesn't start Python at all.

One thing to do before this can merge: main has moved since this branch was cut, and #5477 changed tts.mjs. tts.mjs still merges cleanly, but skills-manifest.json now conflicts. Could you merge main and regenerate the manifest with bun packages/cli/scripts/gen-skills-manifest.ts? The new commit will need one more quick approval, and I'll take care of that.

I didn't run ElevenLabs or test on Windows.

— Rames

# Conflicts:
#	skills-manifest.json
@jrusso1020
jrusso1020 merged commit ea7a4e4 into heygen-com:main Oct 12, 2026
56 checks passed
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.

media-use: ElevenLabs TTS helper reads the text with the locale encoding on Windows (non-ASCII becomes mojibake)

2 participants