Repository navigation
fix(media): read ElevenLabs input as UTF-8 - #5469
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
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-csource, with no file read.gemini-auth.pyalready opens its file withencoding="utf-8"and reconfigures its streams.gemini-tts.mjsdoesn'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
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
tts.test.mjsandtts.spawn.test.mjs: 23 tests passed using the repository test-home setup.git diff --checkpassed.