openai_types/audio/
request.rs1use serde::Serialize;
4
5use super::enums::{AudioResponseFormat, AudioVoice, SpeechResponseFormat};
6
7#[derive(Debug)]
9pub struct TranscriptionParams {
10 pub file: Vec<u8>,
11 pub filename: String,
12 pub model: String,
13 pub language: Option<String>,
14 pub prompt: Option<String>,
15 pub response_format: Option<AudioResponseFormat>,
16 pub temperature: Option<f64>,
17}
18
19impl TranscriptionParams {
20 pub fn new(file: Vec<u8>, filename: impl Into<String>, model: impl Into<String>) -> Self {
21 Self {
22 file,
23 filename: filename.into(),
24 model: model.into(),
25 language: None,
26 prompt: None,
27 response_format: None,
28 temperature: None,
29 }
30 }
31}
32
33#[derive(Debug)]
35pub struct TranslationParams {
36 pub file: Vec<u8>,
37 pub filename: String,
38 pub model: String,
39 pub prompt: Option<String>,
40 pub response_format: Option<AudioResponseFormat>,
41 pub temperature: Option<f64>,
42}
43
44impl TranslationParams {
45 pub fn new(file: Vec<u8>, filename: impl Into<String>, model: impl Into<String>) -> Self {
46 Self {
47 file,
48 filename: filename.into(),
49 model: model.into(),
50 prompt: None,
51 response_format: None,
52 temperature: None,
53 }
54 }
55}
56
57#[derive(Debug, Clone, Serialize)]
59pub struct SpeechRequest {
60 pub input: String,
62 pub model: String,
64 pub voice: AudioVoice,
66 #[serde(skip_serializing_if = "Option::is_none")]
68 pub response_format: Option<SpeechResponseFormat>,
69 #[serde(skip_serializing_if = "Option::is_none")]
71 pub speed: Option<f64>,
72}
73
74impl SpeechRequest {
75 pub fn new(input: impl Into<String>, model: impl Into<String>, voice: AudioVoice) -> Self {
76 Self {
77 input: input.into(),
78 model: model.into(),
79 voice,
80 response_format: None,
81 speed: None,
82 }
83 }
84}