pub struct StreamingTtsRequestBuilder { /* private fields */ }Expand description
Builder for streaming text-to-speech requests.
This builder provides a fluent API for configuring streaming TTS requests.
Implementations§
Source§impl StreamingTtsRequestBuilder
impl StreamingTtsRequestBuilder
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
§Example
use mimo_api::{Client, Voice};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::from_env()?;
let stream = client.tts_stream("Hello!")
.voice(Voice::DefaultEn)
.send()
.await?;
Ok(())
}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.
§Example
use mimo_api::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::from_env()?;
let stream = client.tts_stream("Hello there!")
.user_message("Speak in a friendly, conversational tone")
.send()
.await?;
Ok(())
}Sourcepub async fn send(self) -> Result<StreamingTtsResponse>
pub async fn send(self) -> Result<StreamingTtsResponse>
Send the streaming TTS request and return the response stream.
§Returns
A StreamingTtsResponse that yields audio data chunks.
§Example
use mimo_api::{Client, Voice};
use futures::StreamExt;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::from_env()?;
let mut stream = client.tts_stream("Hello, world!")
.voice(Voice::DefaultEn)
.send()
.await?;
let mut file = File::create("output.pcm").await?;
let mut total_bytes = 0;
while let Some(result) = stream.next().await {
let audio_bytes = result?;
file.write_all(&audio_bytes).await?;
total_bytes += audio_bytes.len();
}
println!("Total bytes: {}", total_bytes);
Ok(())
}Trait Implementations§
Source§impl Clone for StreamingTtsRequestBuilder
impl Clone for StreamingTtsRequestBuilder
Source§fn clone(&self) -> StreamingTtsRequestBuilder
fn clone(&self) -> StreamingTtsRequestBuilder
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 StreamingTtsRequestBuilder
impl !RefUnwindSafe for StreamingTtsRequestBuilder
impl Send for StreamingTtsRequestBuilder
impl Sync for StreamingTtsRequestBuilder
impl Unpin for StreamingTtsRequestBuilder
impl UnsafeUnpin for StreamingTtsRequestBuilder
impl !UnwindSafe for StreamingTtsRequestBuilder
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