Public declaration syntax from forge-rs/crates/forge-media/src/speech.rs Original source SHA-256: 70552b7d5e97993f9f1ecf278efe005f90936e1402dd4c207c3c5946caeae6f7 Function bodies and constant values are omitted. This is not the complete implementation. Source line 48 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum AudioFormat { /// MP3 — widely supported lossy audio format. #[default] Mp3, /// WAV — uncompressed PCM audio. Wav, /// OGG — open container format, typically with Vorbis or Opus codec. Ogg, /// FLAC — lossless audio compression. Flac, } Source line 77 pub fn mime_type(&self) -> &'static str; Source line 98 pub fn extension(&self) -> &'static str; Source line 133 #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct SpeechOptions { /// The voice identifier to use (e.g., "alloy", "echo", "nova"). /// `None` means the provider's default voice. pub voice: Option, /// The playback speed multiplier (e.g., 0.5 for half speed, 2.0 for double speed). /// `None` means the provider's default speed (typically 1.0). pub speed: Option, /// Output audio format. pub format: AudioFormat } Source line 163 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SpeechResult { /// The raw audio bytes in the format specified by `mime_type`. pub audio: Vec, /// The MIME type of the audio data (e.g., "audio/mpeg"). pub mime_type: String, /// The duration of the generated audio in seconds, if available. /// `None` if the provider does not report duration. pub duration_seconds: Option } Source line 213 #[async_trait] pub trait SpeechProvider: Send + Sync { /// Returns the model identifier (e.g., "tts-1", "tts-1-hd"). fn model_id(&self) -> &str; /// Returns the provider name (e.g., "openai", "elevenlabs"). fn provider_name(&self) -> &str; /// Synthesizes speech from text. /// /// # Arguments /// /// * `text` - The text to convert to speech. /// * `options` - Configuration for voice, speed, and output format. /// /// # Returns /// /// A [`SpeechResult`] containing the generated audio bytes and metadata. /// /// # Errors /// /// * [`ForgeMediaError::SpeechFailed`] -- if the provider returns an error. /// * [`ForgeMediaError::UnsupportedFormat`] -- if the requested format is not supported. async fn speak( &self, text: &str, options: &SpeechOptions, ) -> Result; } Source line 283 pub async fn speak( provider: &dyn SpeechProvider, text: &str, options: &SpeechOptions, ) -> Result;