Skip to main content

async_openai/audio/
audio_.rs

1#![allow(deprecated)]
2use crate::{config::Config, Client, RequestOptions};
3
4use super::{Speech, Transcriptions, Translations, VoiceConsents, Voices};
5
6/// Turn audio into text or text into audio.
7/// Related guide: [Speech to text](https://platform.openai.com/docs/guides/speech-to-text)
8pub struct Audio<'c, C: Config> {
9    client: &'c Client<C>,
10    pub(crate) request_options: RequestOptions,
11}
12
13impl<'c, C: Config> Audio<'c, C> {
14    pub fn new(client: &'c Client<C>) -> Self {
15        Self {
16            client,
17            request_options: RequestOptions::new(),
18        }
19    }
20
21    /// APIs in Speech group.
22    pub fn speech(&self) -> Speech<'_, C> {
23        Speech::new(self.client)
24    }
25
26    /// APIs in Transcription group.
27    pub fn transcription(&self) -> Transcriptions<'_, C> {
28        Transcriptions::new(self.client)
29    }
30
31    /// APIs in Translation group.
32    pub fn translation(&self) -> Translations<'_, C> {
33        Translations::new(self.client)
34    }
35
36    /// APIs in Voice Consents group.
37    pub fn voice_consents(&self) -> VoiceConsents<'_, C> {
38        VoiceConsents::new(self.client)
39    }
40
41    /// APIs in Voices group.
42    pub fn voices(&self) -> Voices<'_, C> {
43        Voices::new(self.client)
44    }
45}