-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathlib.rs
69 lines (63 loc) · 1.4 KB
/
lib.rs
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
#[macro_export]
macro_rules! common_derives {
($item:item) => {
#[derive(
PartialEq,
Debug,
Clone,
serde::Serialize,
serde::Deserialize,
specta::Type,
schemars::JsonSchema,
)]
#[schemars(deny_unknown_fields)]
$item
};
}
common_derives! {
pub struct TranscriptChunk {
pub start: u64,
pub end: u64,
pub text: String,
}
}
common_derives! {
pub struct DiarizationChunk {
pub start: u64,
pub end: u64,
pub speaker: String,
}
}
common_derives! {
pub enum ListenOutputChunk {
Transcribe(TranscriptChunk),
Diarize(DiarizationChunk),
}
}
common_derives! {
pub enum ListenInputChunk {
Audio {
#[serde(serialize_with = "serde_bytes::serialize")]
data: Vec<u8>,
},
End,
}
}
common_derives! {
pub struct ListenParams {
#[specta(type = String)]
#[schemars(with = "String")]
pub language: codes_iso_639::part_1::LanguageCode,
pub static_prompt: String,
pub dynamic_prompt: String,
}
}
impl Default for ListenParams {
fn default() -> Self {
Self {
language: codes_iso_639::part_1::LanguageCode::En,
static_prompt: "".to_string(),
dynamic_prompt: "".to_string(),
}
}
}