Commit 7e04296
committed
refactor(tts): derive OuteTTS helpers from upstream at build time (no hand-copy)
Addresses review feedback on PR #268: the TTS native pipeline reused llama.cpp's
tools/tts/tts.cpp by hand-copying its DSP/prompt/text helpers and default-speaker
strings into tts_dsp.hpp + tts_engine.cpp — a DRY/maintenance hazard that would
silently diverge on every llama.cpp upgrade, and a missing-attribution concern.
tts.cpp cannot simply be added to target_sources: it defines its own main()
(link clash, same reason server.cpp is excluded) and every helper is `static`
(internal linkage — unreachable from another TU). So instead of copying, the
helpers are now DERIVED MECHANICALLY from the pinned upstream source at configure
time:
- cmake/generate-tts-upstream.cmake reads the pinned tools/tts/tts.cpp, keeps the
pre-main() span, strips `static` from the helpers the engine calls (external
linkage), and extracts the two default-speaker literals out of main() into
`extern const` strings. Emits build/tts_generated/tts_upstream_gen.cpp (never
committed; regenerated from whatever tts.cpp the GIT_TAG resolves to, so a
version bump is picked up automatically).
- CMakeLists runs it after FetchContent_MakeAvailable(llama.cpp) and compiles the
generated TU into jllama.
- tts_upstream.h: committed, hand-written declarations of the extracted symbols
(interface only). tts_engine.cpp keeps only our orchestration + the in-memory
WAV writer (tts_wav.hpp, ours). tts_dsp.hpp and all copied helpers are removed.
Fail-loud on drift (same contract as patches/): the generator asserts the
`int main(` anchor, every de-static signature, and both speaker literals; a
rename aborts the configure, a type change fails the link. Silent divergence is
impossible.
Bonus: using upstream's real process_text (which calls replace_numbers_with_words)
fixes the previous digit-drop limitation — English numbers are now spoken.
Verified: jllama builds + links, 454 C++ tests pass, and TtsIntegrationTest
synthesizes a valid 24 kHz WAV end-to-end against the real OuteTTS + WavTokenizer
models.
test_tts_dsp.cpp -> test_tts_wav.cpp (now covers only our WAV writer; the DSP is
upstream's, covered end-to-end by TtsIntegrationTest).1 parent f009837 commit 7e04296
10 files changed
Lines changed: 315 additions & 388 deletions
File tree
- cmake
- src
- main
- cpp
- java/net/ladenthin/llama
- test/cpp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
387 | 419 | | |
388 | 420 | | |
389 | 421 | | |
| |||
744 | 776 | | |
745 | 777 | | |
746 | 778 | | |
747 | | - | |
| 779 | + | |
748 | 780 | | |
749 | 781 | | |
750 | 782 | | |
| |||
915 | 947 | | |
916 | 948 | | |
917 | 949 | | |
918 | | - | |
| 950 | + | |
919 | 951 | | |
920 | | - | |
| 952 | + | |
921 | 953 | | |
922 | 954 | | |
923 | 955 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
154 | 177 | | |
155 | 178 | | |
156 | 179 | | |
| |||
264 | 287 | | |
265 | 288 | | |
266 | 289 | | |
| 290 | + | |
267 | 291 | | |
268 | 292 | | |
269 | 293 | | |
270 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
271 | 302 | | |
272 | 303 | | |
273 | 304 | | |
| |||
412 | 443 | | |
413 | 444 | | |
414 | 445 | | |
415 | | - | |
| 446 | + | |
416 | 447 | | |
417 | 448 | | |
418 | 449 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
519 | | - | |
520 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
0 commit comments