Repository navigation
fix(tts): use the v2 Sec-MS-GEC token for Microsoft Edge TTS - #285
Merged
Merged
Conversation
Microsoft's Read Aloud service now rejects the v1 token with HTTP 403, so the edge provider was dead for every voice. Generate the v2 token (`<16 hex>-<64 hex>`: a CS64 keyed digest joined to a modified SHA-256) and send `Sec-MS-GEC-Version=2-<Chromium version>`, ported from edge-tts 7.3.1.
Owner
|
@Realmagnum thanks for contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(tts): use the v2 Sec-MS-GEC token for Microsoft Edge TTS
Fixes the
edgeTTS provider, which currently fails with HTTP 403 on every request.Why
src/app/services/edge-tts.tsgenerates the v1Sec-MS-GECtoken(
SHA256(ticks + TRUSTED_CLIENT_TOKEN),Sec-MS-GEC-Version=1-…). Microsoft's Read Aloudservice now rejects that with HTTP 403 and expects the v2 token:
Sec-MS-GEC-Version=2-<Chromium>and a
Sec-MS-GECvalue shaped<16 hex>-<64 hex>— a CS64 keyed digest joined by a dash to amodified SHA-256 digest. Bumping the version string alone does not help; the token algorithm has
to change too.
What
src/app/services/edge-tts-drm.ts— the v2 token generator, ported fromrany2/edge-tts
src/edge_tts/drm.py(
generate_sec_ms_gec_v2): modified SHA-256 (custom IV derived from the 7-byte salt, one alteredround constant, two adjusted schedule words) plus the CS64 keyed hash over the same
<ticks><TRUSTED_CLIENT_TOKEN>input, Windows file-time ticks rounded down to 5 minutes.No new dependencies; 32-bit lane arithmetic uses
Math.imul/>>> 0to mirror the Python& 0xFFFFFFFFsemantics. ExportsgenerateSecMsGecV2(unixSeconds: number): string.src/app/services/edge-tts.ts—SEC_MS_GEC_VERSIONis now`2-${CHROMIUM_FULL_VERSION}`and
generateSecMsGec(now)delegates to the v2 generator (exported name and signatureunchanged;
_resetClockSkew()still applies). Removed the now-unused v1 constants and thecreateHashimport.tests/app/services/edge-tts-drm.test.ts— new; pins nine vectors produced by the Pythonreference (
edge_tts.drm.generate_sec_ms_gec_v2) including 5-minute-window rounding andsub-second timestamps.
tests/app/services/edge-tts.test.ts— updated token shape/vector/version expectations.Verification
npm test— 2818 passed, 7 skipped (203 files).npm run typecheckandeslinton the changed files — clean.Notes
SEC_MS_GEC_VERSION: it now reports2-<version>,matching what is sent on the wire.
generateSecMsGecstill returns an uppercase hex string; its shape is now<16 hex>-<64 hex>.Closes #284