Skip to main content

AudioGenerator

Trait AudioGenerator 

Source
pub trait AudioGenerator {
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn generate(
        &self,
        prompt: &str,
    ) -> impl Stream<Item = Result<Vec<u8>, Self::Error>> + Send;
}
Expand description

Generates audio from text prompts.

§Example

ⓘ
use aither::AudioGenerator;
use futures_core::Stream;

struct MyAudioGen;

impl AudioGenerator for MyAudioGen {
    fn generate(&self, prompt: &str) -> impl Stream<Item = aither::audio::Data> + Send {
        futures_lite::stream::iter(Some(vec![0u8; 1024]))
    }
}

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The error type returned by this generator.

Required Methods§

Source

fn generate( &self, prompt: &str, ) -> impl Stream<Item = Result<Vec<u8>, Self::Error>> + Send

Generates audio from text prompt.

Returns a Stream of Data chunks. Synthesis can fail part-way through, so each chunk is fallible rather than silently truncating the audio on error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AudioGenerator for Gemini

Source§

type Error = GeminiError

Source§

fn generate( &self, prompt: &str, ) -> impl Stream<Item = Result<Vec<u8>, <Gemini as AudioGenerator>::Error>> + Send

Source§

impl AudioGenerator for OpenAI

Source§

type Error = OpenAIError

Source§

fn generate( &self, prompt: &str, ) -> impl Stream<Item = Result<Vec<u8>, <OpenAI as AudioGenerator>::Error>> + Send

Implementors§