[Bug]: TTS_PROVIDER=edge always fails with HTTP 403 (Microsoft moved Sec-MS-GEC DRM to v2)
[Bug]: TTS_PROVIDER=edge always fails with HTTP 403 (Microsoft moved Sec-MS-GEC DRM to v2)
What happened?
Setting the built-in Microsoft Edge TTS provider makes every voice reply fail:
TTS_PROVIDER=edge
TTS_VOICE=ru-RU-DmitryNeural
The WebSocket upgrade to
wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?...
is rejected with HTTP 403 and an empty body (x-msedge-ref: … FRA). No audio is ever
produced, for any voice or locale.
Root cause
src/app/services/edge-tts.ts still implements the v1 Sec-MS-GEC DRM token:
export const SEC_MS_GEC_VERSION = `1-${CHROMIUM_FULL_VERSION}`;
// …
const strToHash = `${ticks}${TRUSTED_CLIENT_TOKEN}`;
return createHash("sha256").update(strToHash, "ascii").digest("hex").toUpperCase();
Microsoft's Read Aloud service now requires a v2 token:
Sec-MS-GEC-Version=2-<Chromium version>(current reference:2-143.0.3650.75), and- a
Sec-MS-GECvalue shaped<16 hex>-<64 hex>: a CS64 keyed digest joined by a dash to a modified SHA-256 digest (same<ticks><TRUSTED_CLIENT_TOKEN>input, Windows file-time ticks rounded down to 5 minutes), plus aCookie: muid=<32 hex>;header on the upgrade request.
The reference implementation in
rany2/edge-tts src/edge_tts/drm.py
(generate_sec_ms_gec_v2) already does this; the JS port here is on the old scheme. Bumping only
the version string (1- → 2-) is not enough — it still returns 403.
Reproduction / evidence
- Same host, same network, same 5-minute window:
- bot 0.26.5 (
dist/app/services/edge-tts.js): HTTP 403 on the WebSocket upgrade. - Python
edge-tts7.3.1 (edge_tts.Communicate("Проверка", "ru-RU-DmitryNeural")): synthesizes a valid MP3. - A locally patched
edge-tts.tsthat just calls the v2 generator withSec-MS-GEC-Version=2-143.0.3650.75: valid MP3 (Russian speech, ~45 KB for 7.5 s). So this is not an IP/network block nor a missingmuidcookie — the current code already sendsmuid.
- bot 0.26.5 (
- Environment:
@grinev/[email protected], Node v24.21.0, Linux x64, no API key configured (edgeis documented as keyless).
Suggested fix
Port generate_sec_ms_gec_v2 from edge-tts 7.3.1 (pure functions, no new dependency) and use
Sec-MS-GEC-Version=2-…. A pull request with the implementation and reference-vector tests
follows this issue.
Version
0.26.5 (main 8ffd907).