agentai-audio
Text-to-speech and voice cloning for AgentAI.
SpeechGeneratorspeaks texts and clones voices from your code. OpenAI and ElevenLabs need a voice (a default one or one per request), or the request fails withMissingVoice.- With the
toolboxfeature (on by default),SpeechToolBoxgives an agent thegenerate_speechandlist_voicestools. The model gets only the metadata of the audio as JSON by default (SpeechToolOutput::Metadata), or the audio itself (SpeechToolOutput::Media);with_voiceslimits the voices to an allowlist. No tool clones voices. - Providers in
agentai_audio::provider: OpenAI and compatible servers (OpenAI shuts these speech models down on 2027-01-06), ElevenLabs, Fish Audio and oMLX. oMLX clones voices from a sample kept in aVoiceStorethat you give it explicitly (MemoryVoiceStore); Fish Audio sends samples from such a store with the request, or uses voice models of the account. SpeechRequest::with_voicessets several voices in speaker order, for dialogue models such as Fish Audiodrama-3(the text marks the speakers,<|speaker:0|>, ...). Providers with one voice returnUnsupportedfor more.SpeechRequest::with_timestamps(true)returns the time of every word inSpeechResponse::timestamps(Fish Audio, through its timestamp stream; other providers returnUnsupported).- Audio is returned as an
agentaiMediaand can be saved in anyMediaStoragefromagentai_audio::storage, re-exported fromagentai-core. - TLS features as in
agentai:rustls-ring(default),rustls-aws-lc,native-tls,system-proxy.
use ;
// The provider comes from the model name, the API key from `OPENAI_API_KEY`
let generator = new?
.with_default_voice;
let response = generator.generate.await?;
See the speech_generator, speech_tools, clone_voice and dialogue examples.