1use crate::download::{Download, get_cache_dir};
7use std::{
8 ops::{Deref, DerefMut},
9 path::Path,
10};
11
12static CHECKPOINT_URL: &str =
14 "https://github.com/mzdk100/kokoro/releases/download/V1.1/kokoro-v1.1-zh.onnx";
15
16static VOICES_URL: &str =
18 "https://github.com/mzdk100/kokoro/releases/download/V1.1/voices-v1.1-zh.bin";
19
20#[derive(Debug, Clone)]
25pub struct CheckpointModel(Download);
26
27impl CheckpointModel {
28 pub fn new<P: AsRef<Path>>(path: P) -> Self {
36 Self(Download::new(path, CHECKPOINT_URL))
37 }
38}
39
40impl Deref for CheckpointModel {
41 type Target = Download;
42
43 fn deref(&self) -> &Self::Target {
44 &self.0
45 }
46}
47
48impl DerefMut for CheckpointModel {
49 fn deref_mut(&mut self) -> &mut Self::Target {
50 &mut self.0
51 }
52}
53
54impl Default for CheckpointModel {
55 fn default() -> Self {
62 let cache_dir = get_cache_dir().unwrap().join("kokoro");
63 let path = cache_dir.join("kokoro-v1.1-zh.onnx");
64 Self(Download::new(path, CHECKPOINT_URL))
65 }
66}
67
68#[derive(Debug, Clone)]
73pub struct VoicesData(Download);
74
75impl VoicesData {
76 pub fn new<P: AsRef<Path>>(path: P) -> Self {
84 Self(Download::new(path, VOICES_URL))
85 }
86}
87
88impl Default for VoicesData {
89 fn default() -> Self {
96 let cache_dir = get_cache_dir().unwrap().join("kokoro");
97 let path = cache_dir.join("voices-v1.1-zh.bin");
98 Self(Download::new(path, VOICES_URL))
99 }
100}
101
102impl Deref for VoicesData {
103 type Target = Download;
104
105 fn deref(&self) -> &Self::Target {
106 &self.0
107 }
108}
109
110impl DerefMut for VoicesData {
111 fn deref_mut(&mut self) -> &mut Self::Target {
112 &mut self.0
113 }
114}