rust_ai/xfyun/types/
asr.rs

1#[derive(Clone, Copy, Debug)]
2pub enum Language {
3    /// 中文,通用方言(包括普通话、天津、河北、东北、甘肃、山东、太原)
4    Chinese,
5    /// 英文
6    English,
7    /// 日语
8    Japanese,
9    /// 韩语
10    Korean,
11    /// 俄语
12    Russian,
13    /// 法语
14    French,
15    /// 西班牙语
16    Spanish,
17    /// 越南语
18    Vietnamese,
19    /// 西南官话(包括四川、重庆、云南、贵州)
20    ChineseXinanese,
21    /// 粤语
22    ChineseCantonese,
23    ///  河南
24    ChineseHenanese,
25    /// 维吾尔语
26    ChineseUyghur,
27    /// 藏语
28    ChineseTibetan,
29    /// 阿拉伯语
30    Arabic,
31    /// 德语
32    German,
33    /// 意大利语
34    Italian,
35}
36
37impl Into<&str> for Language {
38    fn into(self) -> &'static str {
39        match self {
40            Self::Chinese => "cn",
41            Self::English => "en",
42            Self::Japanese => "ja",
43            Self::Korean => "ko",
44            Self::Russian => "ru",
45            Self::French => "fr",
46            Self::Spanish => "es",
47            Self::Vietnamese => "vi",
48            Self::Arabic => "ar",
49            Self::ChineseXinanese => "cn_xinanese",
50            Self::ChineseCantonese => "cn_cantonese",
51            Self::ChineseHenanese => "cn_henanese",
52            Self::ChineseUyghur => "cn_uyghur",
53            Self::ChineseTibetan => "cn_tibetan",
54            Self::German => "de",
55            Self::Italian => "it",
56        }
57    }
58}
59
60impl From<&str> for Language {
61    fn from(value: &str) -> Self {
62        match value {
63            "cn" => Self::Chinese,
64            "en" => Self::English,
65            "ja" => Self::Japanese,
66            "ko" => Self::Korean,
67            "ru" => Self::Russian,
68            "fr" => Self::French,
69            "es" => Self::Spanish,
70            "vi" => Self::Vietnamese,
71            "ar" => Self::Arabic,
72            "cn_xinanese" => Self::ChineseXinanese,
73            "cn_cantonese" => Self::ChineseCantonese,
74            "cn_henanese" => Self::ChineseHenanese,
75            "cn_uyghur" => Self::ChineseUyghur,
76            "cn_tibetan" => Self::ChineseTibetan,
77            "de" => Self::German,
78            "it" => Self::Italian,
79            _ => panic!("Unsupported input value: {}", value),
80        }
81    }
82}
83
84impl serde::Serialize for Language {
85    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
86    where
87        S: serde::Serializer,
88    {
89        serializer.serialize_str(Into::<&'static str>::into(self.clone()))
90    }
91}
92
93#[derive(Clone, Copy, Debug)]
94pub enum ProfessionalDomain {
95    /// 法律
96    Court,
97    /// 教育
98    Edu,
99    /// 金融
100    Finance,
101    /// 医疗
102    Medical,
103    /// 科技
104    Tech,
105    /// 人文历史
106    Culture,
107    /// 运营商
108    Isp,
109    /// 体育
110    Sport,
111    /// 政府
112    Gov,
113    /// 游戏
114    Game,
115    /// 电商
116    Ecom,
117    /// 军事
118    Mil,
119    /// 企业
120    Com,
121    /// 生活
122    Life,
123    /// 娱乐
124    Ent,
125    /// 汽车
126    Car,
127}
128
129impl Into<&str> for ProfessionalDomain {
130    fn into(self) -> &'static str {
131        match self {
132            Self::Court => "court",
133            Self::Edu => "edu",
134            Self::Finance => "finance",
135            Self::Medical => "medical",
136            Self::Tech => "tech",
137            Self::Culture => "culture",
138            Self::Isp => "isp",
139            Self::Sport => "sport",
140            Self::Gov => "gov",
141            Self::Game => "game",
142            Self::Ecom => "ecom",
143            Self::Mil => "mil",
144            Self::Com => "com",
145            Self::Life => "life",
146            Self::Ent => "ent",
147            Self::Car => "car",
148        }
149    }
150}
151
152impl From<&str> for ProfessionalDomain {
153    fn from(value: &str) -> Self {
154        match value {
155            "court" => Self::Court,
156            "edu" => Self::Edu,
157            "finance" => Self::Finance,
158            "medical" => Self::Medical,
159            "tech" => Self::Tech,
160            "culture" => Self::Culture,
161            "isp" => Self::Isp,
162            "sport" => Self::Sport,
163            "gov" => Self::Gov,
164            "game" => Self::Game,
165            "ecom" => Self::Ecom,
166            "mil" => Self::Mil,
167            "com" => Self::Com,
168            "life" => Self::Life,
169            "ent" => Self::Ent,
170            "car" => Self::Car,
171            _ => panic!("Unsupported value: {}", value),
172        }
173    }
174}
175
176impl serde::Serialize for ProfessionalDomain {
177    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
178    where
179        S: serde::Serializer,
180    {
181        serializer.serialize_str(Into::<&'static str>::into(self.clone()))
182    }
183}
184
185#[derive(Clone, Copy, Debug)]
186pub enum AudioMode {
187    /// 文件流
188    FileStream,
189    /// 音频url外链
190    ExternalUrl,
191}
192
193impl Into<&str> for AudioMode {
194    fn into(self) -> &'static str {
195        match self {
196            Self::FileStream => "fileStream",
197            Self::ExternalUrl => "urlLink",
198        }
199    }
200}
201
202impl From<&str> for AudioMode {
203    fn from(value: &str) -> Self {
204        match value {
205            "fileStream" => Self::FileStream,
206            "urlLink" => Self::ExternalUrl,
207            _ => panic!("Unsupported value: {value}"),
208        }
209    }
210}
211impl serde::Serialize for AudioMode {
212    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
213    where
214        S: serde::Serializer,
215    {
216        serializer.serialize_str(Into::<&'static str>::into(self.clone()))
217    }
218}
219
220#[derive(Clone, Copy, Debug)]
221pub enum WavType {
222    /// 标准pcm/wav
223    StandardWav,
224    /// 非标准 wav (默认)
225    NonstandardWav,
226}
227
228impl Into<u8> for WavType {
229    fn into(self) -> u8 {
230        match self {
231            Self::StandardWav => 1,
232            Self::NonstandardWav => 0,
233        }
234    }
235}
236
237impl From<u8> for WavType {
238    fn from(value: u8) -> Self {
239        match value {
240            1 => Self::StandardWav,
241            0 => Self::NonstandardWav,
242            _ => panic!("Unsupported value: {value}"),
243        }
244    }
245}
246impl serde::Serialize for WavType {
247    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
248    where
249        S: serde::Serializer,
250    {
251        serializer.serialize_u8(Into::<u8>::into(self.clone()))
252    }
253}
254
255#[derive(Clone, Copy, Debug)]
256pub enum LanguageMixType {
257    /// 自动中英文模式
258    MixedChineseEnglish,
259    /// 中文模式(可能包含少量英文)
260    MainlyChinese,
261    /// 纯中文模式(不包含英文)
262    ChineseOnly,
263}
264
265impl Into<u8> for LanguageMixType {
266    fn into(self) -> u8 {
267        match self {
268            Self::MixedChineseEnglish => 1,
269            Self::MainlyChinese => 2,
270            Self::ChineseOnly => 4,
271        }
272    }
273}
274
275impl From<u8> for LanguageMixType {
276    fn from(value: u8) -> Self {
277        match value {
278            1 => Self::MixedChineseEnglish,
279            2 => Self::MainlyChinese,
280            4 => Self::ChineseOnly,
281            _ => panic!("Unsupported value: {value}"),
282        }
283    }
284}
285impl serde::Serialize for LanguageMixType {
286    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
287    where
288        S: serde::Serializer,
289    {
290        serializer.serialize_u8(Into::<u8>::into(self.clone()))
291    }
292}