Public declaration syntax from forge-rs/crates/forge-media/src/transcription.rs Original source SHA-256: 0d553e0ce09c44ab7d4599d73d30579be9edb08e6f71a561b51d978df8a484a3 Function bodies and constant values are omitted. This is not the complete implementation. Source line 54 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct TranscriptionSegment { /// The start time of this segment in seconds from the beginning of the audio. pub start: f64, /// The end time of this segment in seconds from the beginning of the audio. pub end: f64, /// The transcribed text for this segment. pub text: String } Source line 78 pub fn duration(&self) -> f64; Source line 101 #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct TranscriptionOptions { /// An ISO 639-1 language code hint (e.g., "en", "fr", "de"). /// `None` means the provider will auto-detect the language. pub language: Option, /// An optional prompt to guide the transcription model. Useful for providing /// context about domain-specific terminology or expected content. /// `None` means no guidance prompt. pub prompt: Option } Source line 142 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct TranscriptionResult { /// The full transcribed text. pub text: String, /// The detected language as an ISO 639-1 code, if available. pub language: Option, /// The total duration of the audio in seconds, if available. pub duration_seconds: Option, /// Time-aligned transcription segments. May be empty if the provider /// does not support segmented output. pub segments: Vec } Source line 198 #[async_trait] pub trait TranscriptionProvider: Send + Sync { /// Returns the model identifier (e.g., "whisper-1", "chirp-v2"). fn model_id(&self) -> &str; /// Returns the provider name (e.g., "openai", "google"). fn provider_name(&self) -> &str; /// Transcribes audio data to text. /// /// # Arguments /// /// * `audio` - Raw audio bytes. The provider determines acceptable formats /// (e.g., WAV, MP3, FLAC, OGG). /// * `options` - Configuration for language hint and guidance prompt. /// /// # Returns /// /// A [`TranscriptionResult`] containing the transcribed text and metadata. /// /// # Errors /// /// * [`ForgeMediaError::TranscriptionFailed`] -- if the provider returns an error. /// * [`ForgeMediaError::UnsupportedFormat`] -- if the audio format is not supported. async fn transcribe( &self, audio: &[u8], options: &TranscriptionOptions, ) -> Result; } Source line 273 pub async fn transcribe( provider: &dyn TranscriptionProvider, audio: &[u8], options: &TranscriptionOptions, ) -> Result;