Skip to content

--batch-jsonl emits invalid JSON: backslashes in the file field are not escaped (every line on Windows) #119

Description

@raykuo998

--batch-jsonl writes the file field into the output line without JSON string escaping, so every line whose path contains a backslash is invalid JSON — i.e. every line on Windows. The text field is escaped correctly; only file bypasses it.

Observed at commit 5a5a496.

Repro

transcribe-cli.exe --batch list.txt -m moss-Q4_K_M.gguf --backend cpu --batch-jsonl --timestamps none -q > out.jsonl

where list.txt holds absolute Windows paths, one per line:

C:\Users\rayku\AppData\Local\Temp\claude\C--Users-rayku\9b32cefe-...\scratchpad\rg\h1.wav

Then parse it with any strict JSON parser:

node -e "require('fs').readFileSync('out.jsonl','utf8').trim().split('\n').map(JSON.parse)"

Expected

Every output line is valid JSON, with backslashes escaped:

{"file":"C:\\Users\\rayku\\...\\h1.wav","text":"...","mel_ms":11.0,"encode_ms":9109.9,"decode_ms":1879.4}

Actual

Backslashes are emitted raw, producing invalid string escapes (\U, \r, \9, … depending on the path):

{"file":"C:\Users\rayku\AppData\Local\Temp\claude\C--Users-rayku\9b32cefe-...\scratchpad\rg\h1.wav","text":"[0.65][S01]前程部烧进AI的不是SpaceX吗?[3.56]","mel_ms":11.0,"encode_ms":9109.9,"decode_ms":1879.4}
SyntaxError: Bad escaped character in JSON at position 12

JSON.parse / json.loads throw on every such line, which defeats the purpose of --batch-jsonl.

Environment

Windows 11 ARM64. Path handling here is OS-level, not arch-specific — any Windows build should reproduce it. A POSIX path containing a " or a backslash would hit the same code path.

Fix

Run the file value through the same JSON string escaper already used for text before writing it.

Workaround used downstream

Ignore the file field, rely on input list order, and regex text out of the raw line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions