pub struct TtsRequestBuilder { /* private fields */ }Expand description
Builder for text-to-speech requests.
This builder provides a fluent API for configuring TTS requests.
Implementations§
Source§impl TtsRequestBuilder
impl TtsRequestBuilder
Sourcepub fn voice(self, voice: Voice) -> Self
pub fn voice(self, voice: Voice) -> Self
Set the voice for synthesis.
Available voices:
Voice::MimoDefault- MiMo default voice (balanced tone)Voice::DefaultEn- Default English female voiceVoice::DefaultZh- Default Chinese female voice
Sourcepub fn format(self, format: AudioFormat) -> Self
pub fn format(self, format: AudioFormat) -> Self
Set the audio output format.
Available formats:
AudioFormat::Wav- WAV format (recommended for high quality)AudioFormat::Mp3- MP3 format (smaller file size)AudioFormat::Pcm- PCM format (for streaming)
Sourcepub fn user_message(self, message: impl Into<String>) -> Self
pub fn user_message(self, message: impl Into<String>) -> Self
Add a user message to influence the synthesis style.
The user message can help adjust the tone and style of the synthesized speech.
Sourcepub async fn send(self) -> Result<TtsResponse>
pub async fn send(self) -> Result<TtsResponse>
Send the TTS request and return the response.
§Returns
A TtsResponse containing the synthesized audio data.
§Example
use mimo_api::{Client, Voice, AudioFormat};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::from_env()?;
let response = client.tts("Hello, world!")
.voice(Voice::DefaultEn)
.format(AudioFormat::Mp3)
.send()
.await?;
let audio = response.audio()?;
println!("Audio ID: {}", audio.id);
println!("Transcript: {:?}", audio.transcript());
Ok(())
}Trait Implementations§
Source§impl Clone for TtsRequestBuilder
impl Clone for TtsRequestBuilder
Source§fn clone(&self) -> TtsRequestBuilder
fn clone(&self) -> TtsRequestBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TtsRequestBuilder
impl !RefUnwindSafe for TtsRequestBuilder
impl Send for TtsRequestBuilder
impl Sync for TtsRequestBuilder
impl Unpin for TtsRequestBuilder
impl UnsafeUnpin for TtsRequestBuilder
impl !UnwindSafe for TtsRequestBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more