Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

fix: force UTF-8 on Python stdout/stderr and AI CLI capture on Windows (#12)

Nika Siradzeb0b4a823fa0a
diff --git a/backend/cli.py b/backend/cli.py
index 3b8cd90..9bf6a98 100644
--- a/backend/cli.py
+++ b/backend/cli.py
@@ -18,6 +18,14 @@ import sys
import textwrap
import time
+# Windows stdout/stderr default to cp1252, which can't encode chars like '→'; output is UTF-8.
+for _stream in (sys.stdout, sys.stderr):
+ if hasattr(_stream, "reconfigure"):
+ try:
+ _stream.reconfigure(encoding="utf-8", errors="replace")
+ except (ValueError, OSError):
+ pass
+
_env_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".env")
try:
from dotenv import load_dotenv
diff --git a/backend/main.py b/backend/main.py
index 3500810..079ff5c 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -10,6 +10,14 @@ import json
import os
import sys
+# Windows stdout/stderr default to cp1252, which can't encode chars like '→'; IPC is UTF-8.
+for _stream in (sys.stdout, sys.stderr):
+ if hasattr(_stream, "reconfigure"):
+ try:
+ _stream.reconfigure(encoding="utf-8", errors="replace")
+ except (ValueError, OSError):
+ pass
+
# Load .env file (for HF_TOKEN, etc.)
try:
from dotenv import load_dotenv
diff --git a/backend/services/claude_suggest.py b/backend/services/claude_suggest.py
index 8e9fb12..7555c05 100644
--- a/backend/services/claude_suggest.py
+++ b/backend/services/claude_suggest.py
@@ -104,6 +104,8 @@ def _run_ai_command(
],
capture_output=True,
text=True,
+ encoding="utf-8",
+ errors="replace",
cwd=project_dir,
timeout=timeout,
)
@@ -125,6 +127,8 @@ def _run_ai_command(
f'cat "{prompt_file}" | "{cli_path}" --print -p -',
capture_output=True,
text=True,
+ encoding="utf-8",
+ errors="replace",
cwd=project_dir,
timeout=timeout,
shell=True,