use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize)]
pub struct SpeechRequest {
pub input: String,
pub model: String,
pub voice: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub response_format: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub speed: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub instructions: Option<String>,
}
impl SpeechRequest {
pub fn new(
model: impl Into<String>,
input: impl Into<String>,
voice: impl Into<String>,
) -> Self {
Self {
input: input.into(),
model: model.into(),
voice: voice.into(),
response_format: None,
speed: None,
instructions: None,
}
}
pub fn response_format(mut self, response_format: impl Into<String>) -> Self {
self.response_format = Some(response_format.into());
self
}
pub fn speed(mut self, speed: f64) -> Self {
self.speed = Some(speed);
self
}
pub fn instructions(mut self, instructions: impl Into<String>) -> Self {
self.instructions = Some(instructions.into());
self
}
}
#[derive(Debug, Clone)]
pub struct TranscriptionRequest {
pub model: String,
pub language: Option<String>,
pub prompt: Option<String>,
pub response_format: Option<String>,
pub temperature: Option<f64>,
}
impl TranscriptionRequest {
pub fn new(model: impl Into<String>) -> Self {
Self {
model: model.into(),
language: None,
prompt: None,
response_format: None,
temperature: None,
}
}
pub fn language(mut self, language: impl Into<String>) -> Self {
self.language = Some(language.into());
self
}
pub fn prompt(mut self, prompt: impl Into<String>) -> Self {
self.prompt = Some(prompt.into());
self
}
pub fn temperature(mut self, temperature: f64) -> Self {
self.temperature = Some(temperature);
self
}
pub fn response_format(mut self, response_format: impl Into<String>) -> Self {
self.response_format = Some(response_format.into());
self
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Transcription {
pub text: String,
}