aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / crates / site-builder / tests / voice_catalog.rs
| 1 | //! Aien's pre-recorded voice clips (public/aien/voice): every clip in catalog.json exists, matches |
| 2 | //! its recorded sha256 and size, carries a license and source, and no unlisted audio ships. |
| 3 | use sha2::{Digest, Sha256}; |
| 4 | use std::collections::BTreeSet; |
| 5 | use std::fs; |
| 6 | use std::path::Path; |
| 7 | |
| 8 | #[test] |
| 9 | fn voice_catalog_matches_every_shipped_clip() { |
| 10 | let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../public/aien/voice"); |
| 11 | let cat: serde_json::Value = |
| 12 | serde_json::from_str(&fs::read_to_string(dir.join("catalog.json")).expect("catalog.json")).expect("catalog parses"); |
| 13 | let clips = cat["clips"].as_array().expect("clips array"); |
| 14 | assert_eq!(cat["count"].as_u64(), Some(clips.len() as u64), "count field"); |
| 15 | assert!(clips.len() >= 500, "at least 500 clips, found {}", clips.len()); |
| 16 | let mut listed = BTreeSet::new(); |
| 17 | for c in clips { |
| 18 | let id = c["id"].as_str().expect("id"); |
| 19 | let file = c["file"].as_str().expect("file"); |
| 20 | assert_eq!(file, format!("/aien/voice/{id}.mp3"), "{id}: first-party path"); |
| 21 | assert!(listed.insert(format!("{id}.mp3")), "{id}: duplicate id"); |
| 22 | let bytes = fs::read(dir.join(format!("{id}.mp3"))).unwrap_or_else(|e| panic!("{id}: {e}")); |
| 23 | assert_eq!(bytes.len() as u64, c["bytes"].as_u64().expect("bytes"), "{id}: size"); |
| 24 | let sha: String = Sha256::digest(&bytes).iter().map(|b| format!("{b:02x}")).collect(); |
| 25 | assert_eq!(sha, c["sha256"].as_str().expect("sha256"), "{id}: sha256"); |
| 26 | assert!(c["license"].as_str().map_or(false, |l| !l.is_empty()), "{id}: license"); |
| 27 | assert!(c["source"]["voice_id"].as_str().is_some() && c["source"]["model"].as_str().is_some(), "{id}: source"); |
| 28 | let text = c["text"].as_str().expect("text"); |
| 29 | assert!(!text.contains('\u{2013}') && !text.contains('\u{2014}'), "{id}: no en or em dash"); |
| 30 | // The Qwen models were retired on 2026-11-06 and nothing serves them; a recorded |
| 31 | // clip cannot be dated, so Aien's voice names none of them (small-model-001 withdrawn). |
| 32 | assert!(!text.to_ascii_lowercase().contains("qwen"), "{id}: a recorded clip names a retired Qwen model: {text}"); |
| 33 | // No model answers on /aien/ today, so no clip opens a sentence with what Aien runs on |
| 34 | // (small-model-002 and small-model-003 withdrawn, DRA-30 P3-2). error-busy-001 |
| 35 | // ("The machine I run on also does Drake's own work") plays only when a server is busy. |
| 36 | let lower = text.to_ascii_lowercase(); |
| 37 | assert!(!lower.starts_with("i run on") && !lower.contains(". i run on"), "{id}: a recorded clip says what Aien runs on: {text}"); |
| 38 | } |
| 39 | let shipped: BTreeSet<String> = fs::read_dir(&dir) |
| 40 | .expect("voice dir") |
| 41 | .map(|e| e.expect("entry").file_name().to_string_lossy().into_owned()) |
| 42 | .filter(|n| n.ends_with(".mp3")) |
| 43 | .collect(); |
| 44 | assert_eq!(shipped, listed, "every shipped clip is in the catalog and vice versa"); |
| 45 | } |