alltalk 0.1.0

A client for the AllTalk API
Documentation
// TTS Generation Request Parameters
// 🟠 text_input: The text you want the TTS engine to produce. Use escaped
// double quotes for character speech and asterisks for narrator speech if using
// the narrator function. Example:

// -d "text_input=*This is text spoken by the narrator* \"This is text spoken by
// the character\". This is text not inside quotes."

// 🟠 text_filtering: Filter for text. Options:

// none No filtering. Whatever is sent will go over to the TTS engine as raw
// text, which may result in some odd sounds with some special characters.
// standard Human-readable text and a basic level of filtering, just to clean up
// some special characters. html HTML content. Where you are using HTML entity's
// like " -d "text_filtering=none"
// -d "text_filtering=standard"
// -d "text_filtering=html"
// Example:

// Standard Example: *This is text spoken by the narrator* "This is text spoken
// by the character" This is text not inside quotes. HTML Example: *This is
// text spoken by the narrator* "This is text spoken by the
// character" This is text not inside quotes. None: Will just pass whatever
// characters/text you send at it. 🟠 character_voice_gen: The WAV file name for
// the character's voice.

// -d "character_voice_gen=female_01.wav"

// 🟠 narrator_enabled: Enable or disable the narrator function. If true,
// minimum text filtering is set to standard. Anything between double quotes is
// considered the character's speech, and anything between asterisks is
// considered the narrator's speech.

// -d "narrator_enabled=true"
// -d "narrator_enabled=false"

// 🟠 narrator_voice_gen: The WAV file name for the narrator's voice.

// -d "narrator_voice_gen=male_01.wav"

// 🟠 text_not_inside: Specify the handling of lines not inside double quotes or
// asterisks, for the narrator feature. Options:

// character: Treat as character speech.
// narrator: Treat as narrator speech.
// -d "text_not_inside=character"
// -d "text_not_inside=narrator"

// 🟠 language: Choose the language for TTS. Options:

// ar Arabic
// zh-cn Chinese (Simplified)
// cs Czech
// nl Dutch
// en English
// fr French
// de German
// hi Hindi
// hu Hungarian
// it Italian
// ja Japanese
// ko Korean
// pl Polish
// pt Portuguese
// ru Russian
// es Spanish
// tr Turkish
// -d "language=en"

// 🟠 output_file_name: The name of the output file (excluding the .wav
// extension).

// -d "output_file_name=myoutputfile"

// 🟠 output_file_timestamp: Add a timestamp to the output file name. If true,
// each file will have a unique timestamp; otherwise, the same file name will be
// overwritten each time you generate TTS.

// -d "output_file_timestamp=true"
// -d "output_file_timestamp=false"

// 🟠 autoplay: Enable or disable playing the generated TTS to your standard
// sound output device at time of TTS generation.

// -d "autoplay=true"
// -d "autoplay=false"

// 🟠 autoplay_volume: Set the autoplay volume. Should be between 0.1 and 1.0.
// Needs to be specified in the JSON request even if autoplay is false.

// -d "autoplay_volume=0.8"

#[derive(Debug, Clone)]
pub enum TextFiltering {
  None,
  Standard,
  HTML,
}
impl Default for TextFiltering {
  fn default() -> Self {
    TextFiltering::Standard
  }
}
impl Into<&str> for TextFiltering {
  fn into(self) -> &'static str {
    match self {
      TextFiltering::None => "none",
      TextFiltering::Standard => "standard",
      TextFiltering::HTML => "html",
    }
  }
}

#[derive(Debug, Clone)]
pub enum TextNotInside {
  Character,
  Narrator,
}
impl Default for TextNotInside {
  fn default() -> Self {
    TextNotInside::Character
  }
}
impl Into<&str> for TextNotInside {
  fn into(self) -> &'static str {
    match self {
      TextNotInside::Character => "character",
      TextNotInside::Narrator => "narrator",
    }
  }
}
#[derive(Debug, Clone)]
pub enum Language {
  Arabic,
  ChineseSimplified,
  Czech,
  Dutch,
  English,
  French,
  German,
  Hindi,
  Hungarian,
  Italian,
  Japanese,
  Korean,
  Polish,
  Portuguese,
  Russian,
  Spanish,
  Turkish,
}
impl Default for Language {
  fn default() -> Self {
    Language::English
  }
}

impl Into<&str> for Language {
  fn into(self) -> &'static str {
    match self {
      Language::Arabic => "ar",
      Language::ChineseSimplified => "zh-cn",
      Language::Czech => "cs",
      Language::Dutch => "nl",
      Language::English => "en",
      Language::French => "fr",
      Language::German => "de",
      Language::Hindi => "hi",
      Language::Hungarian => "hu",
      Language::Italian => "it",
      Language::Japanese => "ja",
      Language::Korean => "ko",
      Language::Polish => "pl",
      Language::Portuguese => "pt",
      Language::Russian => "ru",
      Language::Spanish => "es",
      Language::Turkish => "tr",
    }
  }
}

impl From<&str> for Language {
  fn from(s: &str) -> Self {
    match s {
      "ar" => Language::Arabic,
      "zh-cn" => Language::ChineseSimplified,
      "cs" => Language::Czech,
      "nl" => Language::Dutch,
      "en" => Language::English,
      "fr" => Language::French,
      "de" => Language::German,
      "hi" => Language::Hindi,
      "hu" => Language::Hungarian,
      "it" => Language::Italian,
      "ja" => Language::Japanese,
      "ko" => Language::Korean,
      "pl" => Language::Polish,
      "pt" => Language::Portuguese,
      "ru" => Language::Russian,
      "es" => Language::Spanish,
      "tr" => Language::Turkish,
      _ => Language::English,
    }
  }
}

impl From<String> for Language {
  fn from(s: String) -> Self {
    Language::from(s.as_str())
  }
}

#[derive(Debug, Clone)]
pub struct TTSModelOptions {
  pub text_input: String,
  pub text_filtering: TextFiltering,
  pub character_voice_gen: String,
  pub narrator_enabled: bool,
  pub narrator_voice_gen: String,
  pub text_not_inside: TextNotInside,
  pub language: Language,
  pub output_file_name: String,
  pub output_file_timestamp: bool,
  pub autoplay: bool,
  pub autoplay_volume: f32,
}

impl Default for TTSModelOptions {
  fn default() -> Self {
    TTSModelOptions {
      text_input: String::new(),
      text_filtering: TextFiltering::default(),
      character_voice_gen: String::from("male_01.wav"),
      narrator_enabled: false,
      narrator_voice_gen: String::from("male_01.wav"),
      text_not_inside: TextNotInside::default(),
      language: Language::default(),
      output_file_name: String::from("audio"),
      output_file_timestamp: true,
      autoplay: false,
      autoplay_volume: 0.8,
    }
  }
}