async_openai/audio/
audio_.rs

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