feat(tts): add Microsoft Edge TTS provider#168
Open
hagope wants to merge 1 commit into
Open
Conversation
Adds a fourth TTS provider that uses Microsoft Edge's online Read Aloud service via WebSocket. No API key, account, or TTS_API_URL required; only outbound HTTPS/WebSocket access to speech.platform.bing.com. Implementation ports the protocol from the Python edge-tts reference (https://github.com/rany2/edge-tts): - Sec-MS-GEC DRM token: SHA256 of Windows file-time ticks (rounded to 5 min) + trusted client token, with single 403 retry that corrects clock skew from the server Date header - SSML framing with prosody rate/volume/pitch and 4096-byte UTF-8-safe chunking that never splits multi-byte chars or XML entities - WebSocket message handling: binary frames use a 2-byte big-endian header-length prefix (length includes the trailing CRLF), audio starts at offset 2 + headerLength; text frames signal turn.end per chunk Adds ws as a runtime dependency (Node 20+ target; global WebSocket is only stable from Node 22+). - New: src/app/services/edge-tts.ts + tests - Wire 'edge' provider into config.ts and tts-service.ts - isTtsConfigured() returns true for edge (no credentials needed) - Document provider in .env.example and PRODUCT.md
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.
Summary
Adds Microsoft Edge TTS as a fourth TTS provider (
TTS_PROVIDER=edge). It uses Microsoft Edge's online Read Aloud service via WebSocket — no API key, account, orTTS_API_URLrequired; only outbound HTTPS/WebSocket access tospeech.platform.bing.com.Implementation ports the protocol from the Python edge-tts reference.
How it works
Sec-MS-GEC): SHA256 of Windows file-time ticks (rounded to 5 min) + trusted client token. Includes a single 403 retry that corrects clock skew from the server'sDateheader.\r\n), so audio starts at offset2 + headerLength; text frames signalturn.endper chunk.audio-24khz-48kbitrate-mono-mp3.Changes
src/app/services/edge-tts.ts+tests/app/services/edge-tts.test.ts'edge'provider intosrc/config.tsandsrc/app/services/tts-service.tsisTtsConfigured()returnstruefor edge (no credentials needed).env.exampleandPRODUCT.mdwsas a runtime dependency (Node 20+ target; the globalWebSocketis only stable from Node 22+)Configuration
Verification
npm run build✓npm run lint✓ (zero warnings)npm test— all new tests pass (16 in edge-tts.test.ts + 4 edge cases in tts-service.test.ts)tests/config.test.ts(env-var leakage ofTTS_MODEL) confirmed to also fail onmainbefore this PR