clawft_plugin/voice/
models.rs1use std::path::PathBuf;
7
8pub struct ModelDownloadManager {
10 cache_dir: PathBuf,
11}
12
13#[derive(Debug, Clone)]
15pub struct ModelInfo {
16 pub id: String,
18 pub url: String,
20 pub sha256: String,
22 pub size_bytes: u64,
24}
25
26impl ModelDownloadManager {
27 pub fn new(cache_dir: PathBuf) -> Self {
29 Self { cache_dir }
30 }
31
32 pub fn cache_dir(&self) -> &PathBuf {
34 &self.cache_dir
35 }
36
37 pub fn is_cached(&self, model: &ModelInfo) -> bool {
39 let model_path = self.cache_dir.join(&model.id);
40 model_path.exists()
41 }
42
43 pub fn model_path(&self, model_id: &str) -> PathBuf {
45 self.cache_dir.join(model_id)
46 }
47
48 pub fn available_stt_models() -> Vec<ModelInfo> {
50 vec![
51 ModelInfo {
52 id: "sherpa-onnx-streaming-zipformer-en-20M".into(),
53 url: "https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-en-20M.tar.bz2".into(),
54 sha256: "PLACEHOLDER_SHA256_STT".into(),
55 size_bytes: 20_000_000,
56 },
57 ]
58 }
59
60 pub fn available_tts_models() -> Vec<ModelInfo> {
62 vec![
63 ModelInfo {
64 id: "vits-piper-en_US-amy-medium".into(),
65 url: "https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-amy-medium.tar.bz2".into(),
66 sha256: "PLACEHOLDER_SHA256_TTS".into(),
67 size_bytes: 40_000_000,
68 },
69 ]
70 }
71
72 pub fn available_vad_models() -> Vec<ModelInfo> {
74 vec![
75 ModelInfo {
76 id: "silero-vad-v5".into(),
77 url: "https://github.com/snakers4/silero-vad/raw/master/files/silero_vad.onnx".into(),
78 sha256: "PLACEHOLDER_SHA256_VAD".into(),
79 size_bytes: 2_000_000,
80 },
81 ]
82 }
83}