diff options
| author | salmonik <salmonik@tuta.io> | 2026-09-05 19:35:21 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-09-05 19:35:21 +0200 |
| commit | 8e868894cbcaf421c263f3555af4d29bef653420 (patch) | |
| tree | a6b6f1de5caeef59367e52a8b7cfa6c2cd9f201d /build.rs | |
| parent | remove ` from TTS and make events use lang.rs (diff) | |
| download | senator-sperma-8e868894cbcaf421c263f3555af4d29bef653420.tar.gz senator-sperma-8e868894cbcaf421c263f3555af4d29bef653420.zip | |
feat: piper now not a subprocess, cache system for TTS
Diffstat (limited to '')
| -rw-r--r-- | build.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..d152090 --- /dev/null +++ b/build.rs | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | fn main() { | ||
| 2 | // espeak-rs-sys builds espeak-ng from source but misses linking sonic | ||
| 3 | // and the speechPlayer audio_object symbols. piper-rs only uses | ||
| 4 | // espeak-ng for phonemization (never audio output), so stub implementations | ||
| 5 | // satisfy the linker without providing real functionality. | ||
| 6 | |||
| 7 | let out_dir = std::env::var("OUT_DIR").unwrap(); | ||
| 8 | let stubs_c = format!("{}/tts_stubs.c", out_dir); | ||
| 9 | let stubs_o = format!("{}/tts_stubs.o", out_dir); | ||
| 10 | let stubs_a = format!("{}/libtts_stubs.a", out_dir); | ||
| 11 | |||
| 12 | std::fs::write( | ||
| 13 | &stubs_c, | ||
| 14 | r#" | ||
| 15 | #include <stddef.h> | ||
| 16 | typedef void* sonicStream; | ||
| 17 | sonicStream sonicCreateStream(int sampleRate, int channels) { return NULL; } | ||
| 18 | void sonicDestroyStream(sonicStream s) {} | ||
| 19 | void sonicSetSpeed(sonicStream s, float speed) {} | ||
| 20 | float sonicGetSpeed(sonicStream s) { return 1.0f; } | ||
| 21 | void sonicWriteShortToStream(sonicStream s, const short *samples, int n) {} | ||
| 22 | int sonicReadShortFromStream(sonicStream s, short *samples, int n) { return 0; } | ||
| 23 | void sonicFlushStream(sonicStream s) {} | ||
| 24 | typedef void* audio_object_t; | ||
| 25 | int audio_object_open(audio_object_t o) { return 0; } | ||
| 26 | int audio_object_write(audio_object_t o, const void *buf, size_t n) { return (int)n; } | ||
| 27 | int audio_object_close(audio_object_t o) { return 0; } | ||
| 28 | int audio_object_flush(audio_object_t o) { return 0; } | ||
| 29 | int audio_object_drain(audio_object_t o) { return 0; } | ||
| 30 | const char* audio_object_strerror(audio_object_t o, int err) { return "stub"; } | ||
| 31 | audio_object_t create_audio_device_object(void* d, const char* device) { return NULL; } | ||
| 32 | "#, | ||
| 33 | ) | ||
| 34 | .expect("write stubs"); | ||
| 35 | |||
| 36 | // cc -c | ||
| 37 | let status = std::process::Command::new("cc") | ||
| 38 | .args(["-c", &stubs_c, "-o", &stubs_o]) | ||
| 39 | .status() | ||
| 40 | .expect("run cc"); | ||
| 41 | assert!(status.success(), "cc -c failed"); | ||
| 42 | |||
| 43 | // ar rcs | ||
| 44 | let status = std::process::Command::new("ar") | ||
| 45 | .args(["rcs", &stubs_a, &stubs_o]) | ||
| 46 | .status() | ||
| 47 | .expect("run ar"); | ||
| 48 | assert!(status.success(), "ar rcs failed"); | ||
| 49 | |||
| 50 | println!("cargo:rustc-link-search=native={}", out_dir); | ||
| 51 | println!("cargo:rustc-link-lib=static=tts_stubs"); | ||
| 52 | } | ||
