1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use crate::macros::impl_enum_string_serialization;
use std::fmt::{Display, Formatter};
use std::str::FromStr;

/// The voice of a text-to-speech.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Voice {
    /// alloy
    Alloy,
    /// echo
    Echo,
    /// fable
    Fable,
    /// onyx
    Onyx,
    /// nova
    Nova,
    /// shimmer
    Shimmer,
}

impl Default for Voice {
    fn default() -> Self {
        Self::Alloy
    }
}

impl Display for Voice {
    fn fmt(
        &self,
        f: &mut Formatter<'_>,
    ) -> std::fmt::Result {
        match self {
            | Voice::Alloy => {
                write!(f, "alloy")
            },
            | Voice::Echo => {
                write!(f, "echo")
            },
            | Voice::Fable => {
                write!(f, "fable")
            },
            | Voice::Onyx => {
                write!(f, "onyx")
            },
            | Voice::Nova => {
                write!(f, "nova")
            },
            | Voice::Shimmer => {
                write!(f, "shimmer")
            },
        }
    }
}

impl FromStr for Voice {
    type Err = crate::ValidationError<String>;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            | "alloy" => Ok(Self::Alloy),
            | "echo" => Ok(Self::Echo),
            | "fable" => Ok(Self::Fable),
            | "onyx" => Ok(Self::Onyx),
            | "nova" => Ok(Self::Nova),
            | "shimmer" => Ok(Self::Shimmer),
            | _ => Err(crate::ValidationError {
                type_name: "Voice".to_string(),
                reason: "Unknown voice".to_string(),
                value: s.to_string(),
            }),
        }
    }
}

impl_enum_string_serialization!(
    Voice,
    Alloy => "alloy",
    Echo => "echo",
    Fable => "fable",
    Onyx => "onyx",
    Nova => "nova",
    Shimmer => "shimmer"
);