rig_core/client/audio_generation.rs
1#[cfg(feature = "audio")]
2mod audio {
3 use crate::audio_generation::AudioGenerationModel;
4
5 /// A provider client with audio generation capabilities.
6 /// Clone is required for conversions between client types.
7 pub trait AudioGenerationClient {
8 /// The AudioGenerationModel used by the Client
9 type AudioGenerationModel: AudioGenerationModel<Client = Self>;
10
11 /// Create an audio generation model with the given name.
12 ///
13 /// # Example
14 /// ```no_run
15 /// use rig_core::prelude::AudioGenerationClient;
16 /// use rig_core::providers::openai::{Client, self};
17 ///
18 /// # fn run() -> Result<(), Box<dyn std::error::Error>> {
19 /// // Initialize the OpenAI client
20 /// let openai = Client::new("your-open-ai-api-key")?;
21 ///
22 /// let tts = openai.audio_generation_model(openai::TTS_1);
23 /// # Ok(())
24 /// # }
25 /// ```
26 fn audio_generation_model(&self, model: impl Into<String>) -> Self::AudioGenerationModel {
27 Self::AudioGenerationModel::make(self, model)
28 }
29 }
30}
31
32#[cfg(feature = "audio")]
33pub use audio::*;