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
//!
//! A Microsoft Edge online text-to-speech client for Rust.
//!
//! Replicates the Edge browser **Read Aloud** WebSocket protocol against
//! `speech.platform.bing.com`, including the rotating `Sec-MS-GEC` DRM token.
//! 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.
//!
//! ## Quick start
//!
//! ```no_run
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! use kothok_edge_tts::Engine;
//! 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?;
//! # Ok(()) }
//! ```
//!
//! ## Architecture
//!
//! | Module        | Responsibility                                          |
//! |---------------|---------------------------------------------------------|
//! | [`Engine`]    | Swappable TTS-backend trait (mock or replace Edge).     |
//! | [`EdgeTts`]   | Reference `Engine` impl — orchestrates a synthesis turn.|
//! | [`TtsEvent`]  | Streaming events: audio chunks, word boundaries, end.   |
//! | [`TtsError`]  | Crate-level error enum.                                 |
//!
//! Internal modules (`auth`, `connection`, `protocol`, `ssml`) are crate-private.
//!
//! > **Note:** this uses the *undocumented* consumer endpoint that Edge's Read
//! > Aloud feature targets. Microsoft can rotate the `SEC_MS_GEC_VERSION`
//! > constant (it 403s when stale); re-pin it and republish when that happens.

mod auth;
mod connection;
mod edge_tts;
mod error;
mod event;
mod protocol;
mod ssml;
mod tts;

pub use edge_tts::EdgeTts;
pub use error::TtsError;
pub use event::TtsEvent;
pub use tts::Engine;

/// Install rustls's `ring` crypto provider.
///
/// rustls 0.23 requires an explicit crypto provider before any TLS handshake.
/// Call this **once** at startup, before the first [`EdgeTts`] connect.
/// Idempotent — safe to call multiple times.
pub fn init_tls() {
    // best-effort: idempotent — the provider may already be installed by the host
    let _ = rustls::crypto::ring::default_provider().install_default();
}