pub struct ResponseAudio {
pub id: String,
pub data: String,
pub expires_at: Option<i64>,
pub transcript: Option<String>,
}Expand description
Response audio data from text-to-speech.
Fields§
§id: StringAudio ID
data: StringBase64 encoded audio data
expires_at: Option<i64>Expiration timestamp (Unix timestamp)
transcript: Option<String>Audio transcript (text that was synthesized)
Implementations§
Source§impl ResponseAudio
impl ResponseAudio
Sourcepub fn decode_data(&self) -> Result<Vec<u8>, DecodeError>
pub fn decode_data(&self) -> Result<Vec<u8>, DecodeError>
Decode the base64 audio data to bytes.
§Example
use mimo_api::{Client, Audio, Voice, Message};
#[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)
.send()
.await?;
let audio = response.audio()?;
let audio_bytes = audio.decode_data()?;
std::fs::write("output.wav", audio_bytes)?;
Ok(())
}Sourcepub fn transcript(&self) -> Option<&str>
pub fn transcript(&self) -> Option<&str>
Get the transcript of the synthesized text.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the audio has expired.
Trait Implementations§
Source§impl Clone for ResponseAudio
impl Clone for ResponseAudio
Source§fn clone(&self) -> ResponseAudio
fn clone(&self) -> ResponseAudio
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 moreSource§impl Debug for ResponseAudio
impl Debug for ResponseAudio
Source§impl<'de> Deserialize<'de> for ResponseAudio
impl<'de> Deserialize<'de> for ResponseAudio
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ResponseAudio
impl RefUnwindSafe for ResponseAudio
impl Send for ResponseAudio
impl Sync for ResponseAudio
impl Unpin for ResponseAudio
impl UnsafeUnpin for ResponseAudio
impl UnwindSafe for ResponseAudio
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