kothok-edge-tts 0.2.2

Microsoft Edge online text-to-speech client — neural voices via the Read Aloud WebSocket protocol (Sec-MS-GEC auth)
Documentation
kothok-edge-tts-0.2.2 has been yanked.

kothok-edge-tts

A Microsoft Edge online text-to-speech client for Rust.

It replicates the Edge browser "Read Aloud" WebSocket protocol against speech.platform.bing.com, including the rotating Sec-MS-GEC DRM token, and returns the same neural voices the browser uses (e.g. en-US-EmmaMultilingualNeural, bn-BD-NabanitaNeural) as streaming MP3 frames plus word-boundary metadata for highlighting.

Features

  • Same neural voices & SSML as Edge's Read Aloud.
  • Pure Rust (no native deps); tokio + tokio-tungstenite + rustls.
  • Swappable backend via the Engine trait.
  • Word-boundary offsets for sentence/word highlighting.
  • Connect skew-retry (handles clock drift → 403).

Quick start

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    kothok_edge_tts::init_tls(); // once, before the first connect

    let events = kothok_edge_tts::EdgeTts
        .synthesize(
            "Hello world.",
            "en-US-EmmaMultilingualNeural",
            "+0%",
            "en-US",
        )
        .await?;

    for ev in events {
        if let kothok_edge_tts::TtsEvent::Audio(bytes) = ev {
            // bytes == MP3 frames (audio-24khz-48kbitrate-mono-mp3)
        }
    }
    Ok(())
}

The Engine trait

use kothok_edge_tts::Engine;

fn speak(engine: &impl Engine) {
    // engine.synthesize(text, voice, rate, lang) -> Future<Result<Vec<TtsEvent>, TtsError>>
}

EdgeTts implements Engine; implement it yourself to mock or swap backends.

Important: token rotation

This targets the undocumented consumer endpoint that Edge's Read Aloud uses. Microsoft rotates the SEC_MS_GEC_VERSION constant on Edge release cycles; when it goes stale every synthesis returns HTTP 403. When that happens, re-pin SEC_MS_GEC_VERSION in src/edge_tts.rs and publish a new version.

License

MIT (LICENSE).