Skip to content

Voice host: force UTF-8 mode for bundled Python (fixes silent TTS on non-CJK Windows) - #8

Open
insxnsive wants to merge 1 commit into
mimimi6666:mainfrom
insxnsive:fix/voice-utf8-encoding
Open

Voice host: force UTF-8 mode for bundled Python (fixes silent TTS on non-CJK Windows)#8
insxnsive wants to merge 1 commit into
mimimi6666:mainfrom
insxnsive:fix/voice-utf8-encoding

Conversation

@insxnsive

@insxnsive insxnsive commented Aug 6, 2026

Copy link
Copy Markdown

Problem

On any Windows system whose ANSI code page cannot represent CJK characters, Lilith's voice is completely silent.

The voice host launches the bundled GPT-SoVITS Python with its stdout/stderr redirected to pipes. On Windows, Python then encodes all output using the locale's ANSI code page. GPT-SoVITS prints the Chinese/Japanese reference transcript on every TTS request, so on cp1252 (all Western European and Latin American locales, incl. en-US and pt-BR), cp1251 (Cyrillic), cp1253, cp1254, cp1256 and others, every request raises:

UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-23: character maps to <undefined>

The API returns 400 {"message":"tts failed", ...} and the mod gives up after its retry window — text chat works, but Lilith never speaks. In practice this affects effectively every non-CJK Windows locale; even Japanese/Korean code pages fail on the mod's Traditional Chinese text.

Fix

Set PYTHONUTF8=1 on the spawned Python process. This enables Python's official UTF-8 mode (PEP 540): stdout/stderr and file I/O become UTF-8 regardless of locale, fixing both the Chinese (zh) and Japanese (ja) voice services on all systems.

Testing

Reproduced on a pt-BR Windows system (cp1252): every TTS request returned the charmap 400. With the fix, both Chinese and English synthesis return 200 with valid WAV audio (~9s for a sentence on CPU).

Notes

Fixes the 'charmap' codec crash that silences TTS on non-CJK Windows
locales (cp1252/cp1251/etc.). PYTHONUTF8=1 (PEP 540) makes stdout/stderr
and file I/O UTF-8 for the spawned GPT-SoVITS process regardless of the
system ANSI code page.
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