use serde::Serialize;
use validator::Validate;
use super::super::traits::*;
#[derive(Debug, Clone, Serialize, Validate)]
pub struct VoiceCloneBody<N>
where
N: ModelName + VoiceClone + Serialize,
{
pub model: N,
#[validate(length(min = 1, max = 128))]
pub voice_name: String,
#[validate(length(min = 1, max = 4096))]
pub input: String,
#[validate(length(min = 1))]
pub file_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub request_id: Option<String>,
}
impl<N> VoiceCloneBody<N>
where
N: ModelName + VoiceClone + Serialize,
{
pub fn new(
model: N,
voice_name: impl Into<String>,
input: impl Into<String>,
file_id: impl Into<String>,
) -> Self {
Self {
model,
voice_name: voice_name.into(),
input: input.into(),
file_id: file_id.into(),
text: None,
request_id: None,
}
}
pub fn with_text(mut self, text: impl Into<String>) -> Self {
self.text = Some(text.into());
self
}
pub fn with_request_id(mut self, request_id: impl Into<String>) -> Self {
self.request_id = Some(request_id.into());
self
}
}