aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tts_smoke.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-09-05 19:35:21 +0200
committersalmonik <salmonik@tuta.io>2026-09-05 19:35:21 +0200
commit8e868894cbcaf421c263f3555af4d29bef653420 (patch)
treea6b6f1de5caeef59367e52a8b7cfa6c2cd9f201d /tests/tts_smoke.rs
parentremove ` from TTS and make events use lang.rs (diff)
downloadsenator-sperma-8e868894cbcaf421c263f3555af4d29bef653420.tar.gz
senator-sperma-8e868894cbcaf421c263f3555af4d29bef653420.zip
feat: piper now not a subprocess, cache system for TTS
Diffstat (limited to '')
-rw-r--r--tests/tts_smoke.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/tts_smoke.rs b/tests/tts_smoke.rs
new file mode 100644
index 0000000..e98d56d
--- /dev/null
+++ b/tests/tts_smoke.rs
@@ -0,0 +1,54 @@
1//! Smoke test: verify piper-rs loads the Polish model and synthesizes audio.
2
3use std::path::Path;
4
5#[test]
6fn piper_load_and_synthesize() {
7 let model_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("piper");
8 let onnx = model_dir.join("pl_PL-bass-high.onnx");
9 let json = model_dir.join("pl_PL-bass-high.onnx.json");
10
11 assert!(onnx.exists(), "model file missing: {}", onnx.display());
12 assert!(json.exists(), "config file missing: {}", json.display());
13
14 let mut piper =
15 piper_rs::Piper::new(&onnx, &json).expect("failed to load piper model");
16
17 let text = "Kamil sie zespawnił";
18 let (samples, sample_rate) = piper
19 .create(text, false, None, None, None, None)
20 .expect("synthesis failed");
21
22 assert!(!samples.is_empty(), "no samples produced");
23 assert!(sample_rate > 0, "invalid sample rate: {sample_rate}");
24 assert!(
25 samples.len() as u32 > sample_rate / 10,
26 "suspiciously short output: {} samples at {} Hz",
27 samples.len(),
28 sample_rate
29 );
30
31 let duration = samples.len() as f64 / sample_rate as f64;
32 println!(
33 "OK: '{}' → {} samples @ {} Hz ({:.2}s)",
34 text,
35 samples.len(),
36 sample_rate,
37 duration,
38 );
39
40 // Second call measures cached-model synthesis speed
41 let start = std::time::Instant::now();
42 let (samples2, sr2) = piper
43 .create("Kamil jest chujem", false, None, None, None, None)
44 .expect("second synthesis failed");
45 let elapsed = start.elapsed();
46 println!(
47 "Cached: '{}' → {} samples @ {} Hz in {:?}",
48 "Kamil jest chujem",
49 samples2.len(),
50 sr2,
51 elapsed,
52 );
53 assert!(!samples2.is_empty());
54}