Description
This library is a wrapper of MSEdge Read aloud function API. You can use it to synthesize text to speech with many voices MS provided.
Features
| Feature | Description |
|---|---|
blocking (default) |
Synchronous TTS client, stream, and voice list using ureq and tungstenite. |
smol-runtime |
Async runtime based on smol. Enables async client, stream, and voice list. |
tokio-runtime |
Async runtime based on tokio. Enables async client, stream, and voice list. |
proxy |
SOCKS4/5 and HTTP CONNECT proxy support. Pairs with any runtime feature. |
How to use
-
You need get a
SpeechConfigto configure the voice of text to speech.
You can convertVoicetoSpeechConfigsimply. Useget_voices_listfunction to get all available voices.
VoiceandSpeechConfigimplementedserde::Serializeandserde::Deserialize.
For example:use get_voices_list; use SpeechConfig;You can also create
SpeechConfigby yourself. Make sure you know the right voice name and audio format. -
Create a TTS
ClientorStream. Both of them have sync and async version. Example below step 3. -
Synthesize text to speech.
Sync Client
Call client function
MSEdgeTTSClient::synthesizeto synthesize text to speech. This function return TypeSynthesizedAudio, you can getaudio_bytesandaudio_metadata.use ;Sync Stream
Call Sender Stream function
Sender::sendto synthesize text to speech. Call Reader Stream functionReceiver::readto get data.
readreturnOption<SynthesizedResponse>, the response may beAudioBytesorAudioMetadataor None. This is because the MSEdge Read aloud API returns multiple data segment and metadata and other information sequentially.Caution: One
sendcorresponds to multipleread. Nextsendcall will block until there no data to read.readwill block before you call asend.use ; use ;
See all examples.