diff --git a/comparisons/cesame.log b/comparisons/cesame.log new file mode 100644 index 0000000000000000000000000000000000000000..bca2fd279c16d50e20f1cd67c053bfbba8139ed0 --- /dev/null +++ b/comparisons/cesame.log @@ -0,0 +1,66 @@ +/home/spice/projects/tts-model-exploration/speech-dev-remi/comparisons/gen_cesame.py:75: UserWarning: WARNING: Unsloth should be imported before [transformers, peft] to ensure all optimizations are applied. Your code may run slower or encounter memory issues without these optimizations. + +Please restructure your imports with 'import unsloth' at the top of your file. + from unsloth import FastModel +============================================================ +CESAME CSM BASELINE (4-bit) +============================================================ +๐Ÿฆฅ Unsloth: Will patch your computer to enable 2x faster free finetuning. +๐Ÿฆฅ Unsloth Zoo will now patch everything to make training faster! +==((====))== Unsloth 2026.2.1: Fast Csm patching. Transformers: 4.52.3. + \\ /| NVIDIA RTX 6000 Ada Generation. Num GPUs = 1. Max memory: 47.382 GB. Platform: Linux. +O^O/ \_/ \ Torch: 2.10.0+cu128. CUDA: 8.9. CUDA Toolkit: 12.8. Triton: 3.6.0 +\ / Bfloat16 = TRUE. FA [Xformers = 0.0.35. FA2 = False] + "-____-" Free license: http://github.com/unslothai/unsloth +Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored! +unsloth/csm-1b does not have a padding token! Will use pad_token = <|PAD_TOKEN|>. + [neut_book_s06_0336] Azora fit l'รฉloge du dรฉfunt ; mais elle avoua qu'i... + OK (10.0s) + [neut_book_s08_0163] Le lendemain, dรจs le lever du jour, Cyrus Smith et... + OK (10.0s) + [neut_book_s09_0091] ร€ une certaine รฉpoque, la terre n'รฉtait formรฉe que... + OK (10.0s) + [neut_book_s09_0307] L'รฎle Tabor, sorte de cรดte basse, ร  peine รฉmergรฉe ... + OK (7.5s) + [neut_parl_s01_0429] A dรฉfaut, je suggรฉrerai ร  l'Assemblรฉe de le rejete... + OK (4.9s) + [neut_parl_s01_0715] Si peu de choses furent au rendez-vous !... + OK (4.4s) + [neut_parl_s02_0152] Lร , vous รฉvoquez les difficultรฉs de quelques branc... + OK (9.3s) + [neut_parl_s03_0695] Nous refusons ce deux poids, deux mesures.... + OK (5.7s) + [neut_parl_s03_0704] En premiรจre lecture, onze jours et onze nuits ont ... + OK (6.5s) + [neut_parl_s05_0355] Cela ne changera rien ร  la compรฉtitivitรฉ du pays o... + OK (3.7s) + +============================================================ +CESAME CSM FINETUNED (4-bit + LoRA) +============================================================ +Loading LoRA from /home/spice/projects/tts-model-exploration/finetuning/cesame/lora_cesame_v2... +LoRA loaded + [neut_book_s06_0336] Azora fit l'รฉloge du dรฉfunt ; mais elle avoua qu'i... + OK (5.3s) + [neut_book_s08_0163] Le lendemain, dรจs le lever du jour, Cyrus Smith et... + OK (9.5s) + [neut_book_s09_0091] ร€ une certaine รฉpoque, la terre n'รฉtait formรฉe que... + OK (9.4s) + [neut_book_s09_0307] L'รฎle Tabor, sorte de cรดte basse, ร  peine รฉmergรฉe ... + OK (6.0s) + [neut_parl_s01_0429] A dรฉfaut, je suggรฉrerai ร  l'Assemblรฉe de le rejete... + OK (3.3s) + [neut_parl_s01_0715] Si peu de choses furent au rendez-vous !... + OK (2.2s) + [neut_parl_s02_0152] Lร , vous รฉvoquez les difficultรฉs de quelques branc... + OK (3.6s) + [neut_parl_s03_0695] Nous refusons ce deux poids, deux mesures.... + OK (2.8s) + [neut_parl_s03_0704] En premiรจre lecture, onze jours et onze nuits ont ... + OK (5.6s) + [neut_parl_s05_0355] Cela ne changera rien ร  la compรฉtitivitรฉ du pays o... + OK (4.2s) + +Copying original SIWIS audio... + +Done! diff --git a/comparisons/cesame/baseline/neut_book_s06_0336.wav b/comparisons/cesame/baseline/neut_book_s06_0336.wav new file mode 100644 index 0000000000000000000000000000000000000000..c500ffa9c8155b99390999be89ace5a9f44f25e4 --- /dev/null +++ b/comparisons/cesame/baseline/neut_book_s06_0336.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e700fb7e5be88278fd2eac6521ebe0ec9d5b445953cd88d42fc709f0edfd1d84 +size 480044 diff --git a/comparisons/cesame/baseline/neut_book_s08_0163.wav b/comparisons/cesame/baseline/neut_book_s08_0163.wav new file mode 100644 index 0000000000000000000000000000000000000000..f188343e9f10b4e800d165fe3d8669cb7e667ff6 --- /dev/null +++ b/comparisons/cesame/baseline/neut_book_s08_0163.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f676096ab85d0a0f0f0b3c16f8c1b05e959b0a40bee88e79b3353ee381f1e701 +size 480044 diff --git a/comparisons/cesame/baseline/neut_book_s09_0091.wav b/comparisons/cesame/baseline/neut_book_s09_0091.wav new file mode 100644 index 0000000000000000000000000000000000000000..e7d0222740fdc630509cf13f1b7901bacb11faeb --- /dev/null +++ b/comparisons/cesame/baseline/neut_book_s09_0091.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96ab925ce73d4a718b528faeff0f6e99a0557cd63bdee05e00be2c230a6a075f +size 480044 diff --git a/comparisons/cesame/baseline/neut_book_s09_0307.wav b/comparisons/cesame/baseline/neut_book_s09_0307.wav new file mode 100644 index 0000000000000000000000000000000000000000..11ed16a60f9a2c34a49bb3eb3eeeb1e07ffea132 --- /dev/null +++ b/comparisons/cesame/baseline/neut_book_s09_0307.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d72056adcf17ac19ed741ef8872b91083ef98ff04c0cfb526463537e7206009 +size 361004 diff --git a/comparisons/cesame/baseline/neut_parl_s01_0429.wav b/comparisons/cesame/baseline/neut_parl_s01_0429.wav new file mode 100644 index 0000000000000000000000000000000000000000..d84642a9bbf1e591b04a4c74d65e0607b21d3f66 --- /dev/null +++ b/comparisons/cesame/baseline/neut_parl_s01_0429.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:baa12f61f1dcc084fed8d928d57e00f4daafecd64ca03beb4d5f3515d81a721d +size 234284 diff --git a/comparisons/cesame/baseline/neut_parl_s01_0715.wav b/comparisons/cesame/baseline/neut_parl_s01_0715.wav new file mode 100644 index 0000000000000000000000000000000000000000..046898efecec738eb0dba1c8185c726a47225efe --- /dev/null +++ b/comparisons/cesame/baseline/neut_parl_s01_0715.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7ef9938d029f3dc1902d099baa5ff24c413264992259c9f4ce63b0d1cc945e4 +size 211244 diff --git a/comparisons/cesame/baseline/neut_parl_s02_0152.wav b/comparisons/cesame/baseline/neut_parl_s02_0152.wav new file mode 100644 index 0000000000000000000000000000000000000000..ce57a3ee48f9dbfd322fa1f4b46ed7624e0fc5c8 --- /dev/null +++ b/comparisons/cesame/baseline/neut_parl_s02_0152.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd89b227d915905daf43246e9ae8d25bf44a965e3c60bc1f0c9c839ec97031d6 +size 445484 diff --git a/comparisons/cesame/baseline/neut_parl_s03_0695.wav b/comparisons/cesame/baseline/neut_parl_s03_0695.wav new file mode 100644 index 0000000000000000000000000000000000000000..d82288b65bb198db74e81b26ef5873514b48ace9 --- /dev/null +++ b/comparisons/cesame/baseline/neut_parl_s03_0695.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6601923e40267cc29588f4b7f89cd139778707edaf9a3331e58c126034372c90 +size 272684 diff --git a/comparisons/cesame/baseline/neut_parl_s03_0704.wav b/comparisons/cesame/baseline/neut_parl_s03_0704.wav new file mode 100644 index 0000000000000000000000000000000000000000..077ba12b794261f4f1bb450f3f49c586ffb51a59 --- /dev/null +++ b/comparisons/cesame/baseline/neut_parl_s03_0704.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e0eb2e951514b8959052e91a8efa9aae74adfcc97debc83a0b0854632f35017 +size 311084 diff --git a/comparisons/cesame/baseline/neut_parl_s05_0355.wav b/comparisons/cesame/baseline/neut_parl_s05_0355.wav new file mode 100644 index 0000000000000000000000000000000000000000..388f8c0545c8aaa8731b0ed3a04682460e73131e --- /dev/null +++ b/comparisons/cesame/baseline/neut_parl_s05_0355.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:47e034781989f722fe677091074edea7a3d2cc05ca5ce4d92279d7147d873ba9 +size 176684 diff --git a/comparisons/cesame/finetuned/neut_book_s06_0336.wav b/comparisons/cesame/finetuned/neut_book_s06_0336.wav new file mode 100644 index 0000000000000000000000000000000000000000..fe65c1f0a64ef8cef295f8de306d11062faac386 --- /dev/null +++ b/comparisons/cesame/finetuned/neut_book_s06_0336.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98925e885bde31c04f5bb968d2b486c5ec8fe0c7c4e979205903b832927aab08 +size 253484 diff --git a/comparisons/cesame/finetuned/neut_book_s08_0163.wav b/comparisons/cesame/finetuned/neut_book_s08_0163.wav new file mode 100644 index 0000000000000000000000000000000000000000..f652414436fb01e25e954f425c8f2cb9b9058735 --- /dev/null +++ b/comparisons/cesame/finetuned/neut_book_s08_0163.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:739f45c6f739c13ecad8183e25ab3ab77f2af3a6cc0ab3ad31513cb182802f03 +size 457004 diff --git a/comparisons/cesame/finetuned/neut_book_s09_0091.wav b/comparisons/cesame/finetuned/neut_book_s09_0091.wav new file mode 100644 index 0000000000000000000000000000000000000000..0bc4273d436a783578e71364a472a181d41ec3c6 --- /dev/null +++ b/comparisons/cesame/finetuned/neut_book_s09_0091.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26f0c85a95104fe83d52d6ca47bf4b14f5b408cf6679774f0280de78e3ed1cad +size 453164 diff --git a/comparisons/cesame/finetuned/neut_book_s09_0307.wav b/comparisons/cesame/finetuned/neut_book_s09_0307.wav new file mode 100644 index 0000000000000000000000000000000000000000..5c8b797f11890765ccb06e3bb8eec57663e58ae1 --- /dev/null +++ b/comparisons/cesame/finetuned/neut_book_s09_0307.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d8d23cac2dd6fe91ff1b29d444687be8f514c7d2189f2928b96d4c443482742 +size 288044 diff --git a/comparisons/cesame/finetuned/neut_parl_s01_0429.wav b/comparisons/cesame/finetuned/neut_parl_s01_0429.wav new file mode 100644 index 0000000000000000000000000000000000000000..d4257d750f236aa9f68c938f2651f7c0609831dd --- /dev/null +++ b/comparisons/cesame/finetuned/neut_parl_s01_0429.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:967c14acd86c5d04a491175861279624e7dc798b3c41e5b244c40e87e6112895 +size 157484 diff --git a/comparisons/cesame/finetuned/neut_parl_s01_0715.wav b/comparisons/cesame/finetuned/neut_parl_s01_0715.wav new file mode 100644 index 0000000000000000000000000000000000000000..7dc8697d6b079a29eae4a018d05bf07dd0a6223f --- /dev/null +++ b/comparisons/cesame/finetuned/neut_parl_s01_0715.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f323b127a8e697fe0e968458dff1d36c6fdad9e86d8b190f5f2d9f27f962a3ee +size 107564 diff --git a/comparisons/cesame/finetuned/neut_parl_s02_0152.wav b/comparisons/cesame/finetuned/neut_parl_s02_0152.wav new file mode 100644 index 0000000000000000000000000000000000000000..43f144ec622173c38e0e61fb816105f52cc8b760 --- /dev/null +++ b/comparisons/cesame/finetuned/neut_parl_s02_0152.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42b6a8bfa6e59ae2bfcdc002d9461ffc80979c3426bf4636df7593a0195d85da +size 172844 diff --git a/comparisons/cesame/finetuned/neut_parl_s03_0695.wav b/comparisons/cesame/finetuned/neut_parl_s03_0695.wav new file mode 100644 index 0000000000000000000000000000000000000000..11eff2608f7bea4a2904e1c4f93567a2d25a7e0c --- /dev/null +++ b/comparisons/cesame/finetuned/neut_parl_s03_0695.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a9ba9ef7ffda50a73c11a68a250134af8de43283c82b11644435a2a449b504b +size 134444 diff --git a/comparisons/cesame/finetuned/neut_parl_s03_0704.wav b/comparisons/cesame/finetuned/neut_parl_s03_0704.wav new file mode 100644 index 0000000000000000000000000000000000000000..fae95115e78ff85e37311db7d008987d842459be --- /dev/null +++ b/comparisons/cesame/finetuned/neut_parl_s03_0704.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2eb312fc111c85560518c21b8dd1127c3a72564e43646accad3d7ae1dc60340c +size 268844 diff --git a/comparisons/cesame/finetuned/neut_parl_s05_0355.wav b/comparisons/cesame/finetuned/neut_parl_s05_0355.wav new file mode 100644 index 0000000000000000000000000000000000000000..e2f59f38fec74cd5c07d624d246856d7085141f4 --- /dev/null +++ b/comparisons/cesame/finetuned/neut_parl_s05_0355.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad45f92cad09ce312f38ae762df6b8eefa2affc9da6bc2b8bebb33828a9db7ca +size 199724 diff --git a/comparisons/cesame/original/neut_book_s06_0336.wav b/comparisons/cesame/original/neut_book_s06_0336.wav new file mode 100644 index 0000000000000000000000000000000000000000..c10365822706d32896b1ab4176d4181b84b7d899 --- /dev/null +++ b/comparisons/cesame/original/neut_book_s06_0336.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04b4740d8104398d4df427ec1ccbbbdadad600ad4c579c39dd747583749d0710 +size 442008 diff --git a/comparisons/cesame/original/neut_book_s08_0163.wav b/comparisons/cesame/original/neut_book_s08_0163.wav new file mode 100644 index 0000000000000000000000000000000000000000..3f553a8f6ee621bf355ccfeef7cc8787220fa5b1 --- /dev/null +++ b/comparisons/cesame/original/neut_book_s08_0163.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19383c41bd680420559c45d7d9cdf88c59af56600d40a68e6b5e61db145dc8d4 +size 796572 diff --git a/comparisons/cesame/original/neut_book_s09_0091.wav b/comparisons/cesame/original/neut_book_s09_0091.wav new file mode 100644 index 0000000000000000000000000000000000000000..3227a4745cb85f5b1062d0501f500838560c5ff9 --- /dev/null +++ b/comparisons/cesame/original/neut_book_s09_0091.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad2a9d2e5f20d7545a3b8211ca25d4c8205236d90c7209a4a9ab4b13698fd128 +size 763054 diff --git a/comparisons/cesame/original/neut_book_s09_0307.wav b/comparisons/cesame/original/neut_book_s09_0307.wav new file mode 100644 index 0000000000000000000000000000000000000000..b09c99eee819507af09020062af630e65d38f991 --- /dev/null +++ b/comparisons/cesame/original/neut_book_s09_0307.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb49a6f1a20eb7b614e5ac78450e56ee0885d4342fa98b086c035950f2f145ce +size 533736 diff --git a/comparisons/cesame/original/neut_parl_s01_0429.wav b/comparisons/cesame/original/neut_parl_s01_0429.wav new file mode 100644 index 0000000000000000000000000000000000000000..5fb615243813f51100ef7ba932961c8910be78fe --- /dev/null +++ b/comparisons/cesame/original/neut_parl_s01_0429.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e46bafdf9f4ab5f0b56b3c7cb6d6036d29e3199436f0c33a54562a8b1ff8fec +size 304416 diff --git a/comparisons/cesame/original/neut_parl_s01_0715.wav b/comparisons/cesame/original/neut_parl_s01_0715.wav new file mode 100644 index 0000000000000000000000000000000000000000..bbbdc155b61f3ececb0b9b0095c952c78ba8db75 --- /dev/null +++ b/comparisons/cesame/original/neut_parl_s01_0715.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c95152b1d2f044685d3ff6eb9a3a0db5184ec2afb9ab8e969d9319da2bf0bf48 +size 173880 diff --git a/comparisons/cesame/original/neut_parl_s02_0152.wav b/comparisons/cesame/original/neut_parl_s02_0152.wav new file mode 100644 index 0000000000000000000000000000000000000000..c3a41ac19b99154cd527d54ee9aeec1a0d2ba63a --- /dev/null +++ b/comparisons/cesame/original/neut_parl_s02_0152.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c066507c1529fa4b2195ef796fd54ac6e04847494c3fa2b63588a12ddb17dec +size 294714 diff --git a/comparisons/cesame/original/neut_parl_s03_0695.wav b/comparisons/cesame/original/neut_parl_s03_0695.wav new file mode 100644 index 0000000000000000000000000000000000000000..657027f494511f4af5a31aa479a2f7078c240ad0 --- /dev/null +++ b/comparisons/cesame/original/neut_parl_s03_0695.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4024e0aabad4985578ec5da5b2d090ee3f145c3d30b30227b03b72710ef19976 +size 197694 diff --git a/comparisons/cesame/original/neut_parl_s03_0704.wav b/comparisons/cesame/original/neut_parl_s03_0704.wav new file mode 100644 index 0000000000000000000000000000000000000000..e53191ac605aa48fd8899245a22813084a609adb --- /dev/null +++ b/comparisons/cesame/original/neut_parl_s03_0704.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a6c81d7ef9913b0ff0d2de57936901a082e4d52ac736198f6daed38be46c4aea +size 444654 diff --git a/comparisons/cesame/original/neut_parl_s05_0355.wav b/comparisons/cesame/original/neut_parl_s05_0355.wav new file mode 100644 index 0000000000000000000000000000000000000000..66890e644e4da17ff82ae1ea2d12544dd1b99975 --- /dev/null +++ b/comparisons/cesame/original/neut_parl_s05_0355.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e350d8307aae8ecc6f3fc4e99b8bccca995c77cc073230e85782e3406750dff5 +size 329112 diff --git a/comparisons/gen_cesame.py b/comparisons/gen_cesame.py new file mode 100644 index 0000000000000000000000000000000000000000..4c49cb1218f0adced7868b167ec3a01ec59074f3 --- /dev/null +++ b/comparisons/gen_cesame.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python3 +"""Generate 10 proof_unseen texts with CeSAMe baseline + finetuned (LoRA).""" +import torch +import soundfile as sf +import numpy as np +import shutil +from pathlib import Path +from transformers import CsmForConditionalGeneration, AutoProcessor +from peft import PeftModel + +TEXTS = { + "neut_book_s06_0336": "Azora fit l'รฉloge du dรฉfunt ; mais elle avoua qu'il avait des dรฉfauts dont Cador รฉtait exempt.", + "neut_book_s08_0163": "Le lendemain, dรจs le lever du jour, Cyrus Smith et Ayrton, montant le chariot attelรฉ des deux onaggas, prenaient la route du corral et y couraient au grand trot.", + "neut_book_s09_0091": "ร€ une certaine รฉpoque, la terre n'รฉtait formรฉe que d'une รฉcorce รฉlastique, soumise ร  des mouvements alternatifs de haut et de bas, en vertu des lois de l'attraction.", + "neut_book_s09_0307": "L'รฎle Tabor, sorte de cรดte basse, ร  peine รฉmergรฉe des flots, n'รฉtait pas รฉloignรฉe de plus de quinze milles.", + "neut_parl_s01_0429": "A dรฉfaut, je suggรฉrerai ร  l'Assemblรฉe de le rejeter.", + "neut_parl_s01_0715": "Si peu de choses furent au rendez-vous !", + "neut_parl_s02_0152": "Lร , vous รฉvoquez les difficultรฉs de quelques branches spรฉcifiques.", + "neut_parl_s03_0695": "Nous refusons ce deux poids, deux mesures.", + "neut_parl_s03_0704": "En premiรจre lecture, onze jours et onze nuits ont รฉtรฉ consacrรฉs ร  ce texte.", + "neut_parl_s05_0355": "Cela ne changera rien ร  la compรฉtitivitรฉ du pays ou au chรดmage.", +} + +OUTPUT_DIR = Path("/home/spice/projects/tts-model-exploration/speech-dev-remi/comparisons/cesame") +LORA_PATH = Path("/home/spice/projects/tts-model-exploration/finetuning/cesame/lora_cesame_v2") +SAMPLE_RATE = 24000 + +device = torch.device("cuda:0") + + +def generate_all(model, processor, output_subdir): + output_subdir.mkdir(parents=True, exist_ok=True) + for stem, text in TEXTS.items(): + print(f" [{stem}] {text[:50]}...") + try: + text_with_speaker = f"[0]{text}" + inputs = processor(text_with_speaker, add_special_tokens=True, return_tensors="pt").to(device) + + with torch.no_grad(): + audio_output = model.generate(**inputs, output_audio=True) + + if isinstance(audio_output, (list, tuple)) and len(audio_output) > 0: + if isinstance(audio_output[0], torch.Tensor): + audio = audio_output[0].to(torch.float32).cpu().numpy() + elif hasattr(audio_output[0], 'audio_values'): + audio = audio_output[0].audio_values.squeeze().to(torch.float32).cpu().numpy() + else: + raise ValueError(f"Unexpected type: {type(audio_output[0])}") + elif hasattr(audio_output, 'audio_values'): + audio = audio_output.audio_values.squeeze().to(torch.float32).cpu().numpy() + elif isinstance(audio_output, torch.Tensor): + audio = audio_output.squeeze().to(torch.float32).cpu().numpy() + else: + raise ValueError(f"Unexpected output: {type(audio_output)}") + + audio = audio.astype("float32").flatten() + peak = np.max(np.abs(audio)) + if peak > 1.0: + audio = audio / peak * 0.99 + + sf.write(str(output_subdir / f"{stem}.wav"), audio, SAMPLE_RATE) + print(f" OK ({len(audio)/SAMPLE_RATE:.1f}s)") + except Exception as e: + print(f" ERROR: {e}") + import traceback; traceback.print_exc() + + +def main(): + OUTPUT_DIR.mkdir(parents=True, exist_ok=True) + + # --- Baseline (4-bit) --- + print("=" * 60) + print("CESAME CSM BASELINE (4-bit)") + print("=" * 60) + from unsloth import FastModel + model, _tokenizer = FastModel.from_pretrained( + model_name="unsloth/csm-1b", + max_seq_length=2048, + dtype=None, + auto_model=CsmForConditionalGeneration, + load_in_4bit=True, + ) + processor = AutoProcessor.from_pretrained("unsloth/csm-1b") + model.eval() + + generate_all(model, processor, OUTPUT_DIR / "baseline") + + # --- Finetuned (4-bit + LoRA) --- + print("\n" + "=" * 60) + print("CESAME CSM FINETUNED (4-bit + LoRA)") + print("=" * 60) + print(f"Loading LoRA from {LORA_PATH}...") + + # Apply LoRA adapter + model = PeftModel.from_pretrained(model, str(LORA_PATH)) + model.eval() + print("LoRA loaded") + + generate_all(model, processor, OUTPUT_DIR / "finetuned") + + # Copy originals + print("\nCopying original SIWIS audio...") + (OUTPUT_DIR / "original").mkdir(exist_ok=True) + siwis_wavs = Path("/home/spice/speech/app/liquid-audio/french_finetuning/data/raw/siwis/SiwisFrenchSpeechSynthesisDatabase/wavs") + for stem in TEXTS: + src = list(siwis_wavs.rglob(f"{stem}.wav")) + if src: + shutil.copy2(src[0], OUTPUT_DIR / "original" / f"{stem}.wav") + + print("\nDone!") + + +if __name__ == "__main__": + main() diff --git a/comparisons/gen_qwen3tts.py b/comparisons/gen_qwen3tts.py new file mode 100644 index 0000000000000000000000000000000000000000..2518650361480a8149308227d84e641560314f3c --- /dev/null +++ b/comparisons/gen_qwen3tts.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +"""Generate 10 proof_unseen texts with Qwen3-TTS baseline + finetuned.""" +import sys +import torch +import soundfile as sf +import numpy as np +import shutil +from pathlib import Path + +sys.path.insert(0, str(Path("/home/spice/projects/tts-model-exploration/Qwen3-TTS"))) + +from qwen_tts import Qwen3TTSModel + +TEXTS = { + "neut_book_s06_0336": "Azora fit l'รฉloge du dรฉfunt ; mais elle avoua qu'il avait des dรฉfauts dont Cador รฉtait exempt.", + "neut_book_s08_0163": "Le lendemain, dรจs le lever du jour, Cyrus Smith et Ayrton, montant le chariot attelรฉ des deux onaggas, prenaient la route du corral et y couraient au grand trot.", + "neut_book_s09_0091": "ร€ une certaine รฉpoque, la terre n'รฉtait formรฉe que d'une รฉcorce รฉlastique, soumise ร  des mouvements alternatifs de haut et de bas, en vertu des lois de l'attraction.", + "neut_book_s09_0307": "L'รฎle Tabor, sorte de cรดte basse, ร  peine รฉmergรฉe des flots, n'รฉtait pas รฉloignรฉe de plus de quinze milles.", + "neut_parl_s01_0429": "A dรฉfaut, je suggรฉrerai ร  l'Assemblรฉe de le rejeter.", + "neut_parl_s01_0715": "Si peu de choses furent au rendez-vous !", + "neut_parl_s02_0152": "Lร , vous รฉvoquez les difficultรฉs de quelques branches spรฉcifiques.", + "neut_parl_s03_0695": "Nous refusons ce deux poids, deux mesures.", + "neut_parl_s03_0704": "En premiรจre lecture, onze jours et onze nuits ont รฉtรฉ consacrรฉs ร  ce texte.", + "neut_parl_s05_0355": "Cela ne changera rien ร  la compรฉtitivitรฉ du pays ou au chรดmage.", +} + +OUTPUT_DIR = Path("/home/spice/projects/tts-model-exploration/speech-dev-remi/comparisons/qwen3tts") +FINETUNED_PATH = Path("/home/spice/projects/tts-model-exploration/Qwen3-TTS/finetuning/output_v2/checkpoint-best") +BASELINE_MODEL_ID = "Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice" + +device = torch.device("cuda:0") + + +def generate_all(model, output_subdir, speaker="Ryan", language="French"): + output_subdir.mkdir(parents=True, exist_ok=True) + for stem, text in TEXTS.items(): + print(f" [{stem}] {text[:50]}...") + try: + with torch.no_grad(): + wavs, sr = model.generate_custom_voice( + text=text, language=language, speaker=speaker, + ) + audio = wavs[0] + if isinstance(audio, torch.Tensor): + audio = audio.cpu().numpy() + audio = audio.astype("float32").flatten() + peak = np.max(np.abs(audio)) + if peak > 1.0: + audio = audio / peak * 0.99 + sf.write(str(output_subdir / f"{stem}.wav"), audio, sr) + print(f" OK ({len(audio)/sr:.1f}s)") + except Exception as e: + print(f" ERROR: {e}") + + +def main(): + OUTPUT_DIR.mkdir(parents=True, exist_ok=True) + + try: + import flash_attn + attn_impl = "flash_attention_2" + except ImportError: + attn_impl = "sdpa" + + # --- Baseline --- + print("=" * 60) + print("QWEN3-TTS BASELINE") + print("=" * 60) + model = Qwen3TTSModel.from_pretrained( + BASELINE_MODEL_ID, device_map=str(device), + dtype=torch.bfloat16, attn_implementation=attn_impl, + ) + generate_all(model, OUTPUT_DIR / "baseline") + del model + torch.cuda.empty_cache() + + # --- Finetuned --- + print("\n" + "=" * 60) + print("QWEN3-TTS FINETUNED") + print("=" * 60) + print(f"Loading from {FINETUNED_PATH}...") + model = Qwen3TTSModel.from_pretrained( + str(FINETUNED_PATH), device_map=str(device), + dtype=torch.bfloat16, attn_implementation=attn_impl, + ) + generate_all(model, OUTPUT_DIR / "finetuned", speaker="SIWIS_French") + del model + torch.cuda.empty_cache() + + # Copy originals + print("\nCopying original SIWIS audio...") + (OUTPUT_DIR / "original").mkdir(exist_ok=True) + siwis_wavs = Path("/home/spice/speech/app/liquid-audio/french_finetuning/data/raw/siwis/SiwisFrenchSpeechSynthesisDatabase/wavs") + for stem in TEXTS: + src = list(siwis_wavs.rglob(f"{stem}.wav")) + if src: + shutil.copy2(src[0], OUTPUT_DIR / "original" / f"{stem}.wav") + + print("\nDone!") + + +if __name__ == "__main__": + main() diff --git a/comparisons/gen_vibevoice.py b/comparisons/gen_vibevoice.py new file mode 100644 index 0000000000000000000000000000000000000000..27f796f836961a64edbcc279432e4a5e6c44689f --- /dev/null +++ b/comparisons/gen_vibevoice.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 +"""Generate 10 proof_unseen texts with VibeVoice baseline + finetuned.""" +import torch +import copy +import soundfile as sf +import numpy as np +from pathlib import Path +from safetensors.torch import load_file + +from vibevoice.modular.modeling_vibevoice_streaming_inference import ( + VibeVoiceStreamingForConditionalGenerationInference, +) +from vibevoice.processor.vibevoice_streaming_processor import ( + VibeVoiceStreamingProcessor, +) + +TEXTS = { + "neut_book_s06_0336": "Azora fit l'รฉloge du dรฉfunt ; mais elle avoua qu'il avait des dรฉfauts dont Cador รฉtait exempt.", + "neut_book_s08_0163": "Le lendemain, dรจs le lever du jour, Cyrus Smith et Ayrton, montant le chariot attelรฉ des deux onaggas, prenaient la route du corral et y couraient au grand trot.", + "neut_book_s09_0091": "ร€ une certaine รฉpoque, la terre n'รฉtait formรฉe que d'une รฉcorce รฉlastique, soumise ร  des mouvements alternatifs de haut et de bas, en vertu des lois de l'attraction.", + "neut_book_s09_0307": "L'รฎle Tabor, sorte de cรดte basse, ร  peine รฉmergรฉe des flots, n'รฉtait pas รฉloignรฉe de plus de quinze milles.", + "neut_parl_s01_0429": "A dรฉfaut, je suggรฉrerai ร  l'Assemblรฉe de le rejeter.", + "neut_parl_s01_0715": "Si peu de choses furent au rendez-vous !", + "neut_parl_s02_0152": "Lร , vous รฉvoquez les difficultรฉs de quelques branches spรฉcifiques.", + "neut_parl_s03_0695": "Nous refusons ce deux poids, deux mesures.", + "neut_parl_s03_0704": "En premiรจre lecture, onze jours et onze nuits ont รฉtรฉ consacrรฉs ร  ce texte.", + "neut_parl_s05_0355": "Cela ne changera rien ร  la compรฉtitivitรฉ du pays ou au chรดmage.", +} + +OUTPUT_DIR = Path("/home/spice/projects/tts-model-exploration/speech-dev-remi/comparisons/vibevoice") +FINETUNED_WEIGHTS = Path("/home/spice/projects/tts-model-exploration/finetuning_vibevoice/outputs/full_ft_vibevoice/tts_lm_best.safetensors") +VOICES_DIR = Path("/home/spice/speech/VibeVoice/demo/voices/streaming_model") +SAMPLE_RATE = 24000 + +device = torch.device("cuda:0") + + +def load_model(): + model_path = "microsoft/VibeVoice-Realtime-0.5B" + processor = VibeVoiceStreamingProcessor.from_pretrained(model_path) + try: + model = VibeVoiceStreamingForConditionalGenerationInference.from_pretrained( + model_path, torch_dtype=torch.bfloat16, device_map=str(device), + attn_implementation="flash_attention_2", + ) + except Exception: + model = VibeVoiceStreamingForConditionalGenerationInference.from_pretrained( + model_path, torch_dtype=torch.bfloat16, device_map=str(device), + attn_implementation="sdpa", + ) + model.eval() + model.set_ddpm_inference_steps(num_steps=5) + return model, processor + + +def generate_sample(model, processor, text, voice_prompt): + inputs = processor.process_input_with_cached_prompt( + text=text, cached_prompt=voice_prompt, + padding=True, return_tensors="pt", return_attention_mask=True, + ) + for k, v in inputs.items(): + if torch.is_tensor(v): + inputs[k] = v.to(device) + + max_tokens = min(max(int(len(text) * 3.0) + 100, 200), 800) + + with torch.no_grad(): + outputs = model.generate( + **inputs, max_new_tokens=max_tokens, cfg_scale=1.5, + tokenizer=processor.tokenizer, + generation_config={'do_sample': False}, verbose=False, + all_prefilled_outputs=copy.deepcopy(voice_prompt), + ) + + if not outputs.speech_outputs or outputs.speech_outputs[0] is None: + return None + audio = outputs.speech_outputs[0].cpu().float().numpy().flatten() + peak = np.max(np.abs(audio)) + if peak > 1.0: + audio = audio / peak * 0.99 + return audio + + +def main(): + OUTPUT_DIR.mkdir(parents=True, exist_ok=True) + (OUTPUT_DIR / "baseline").mkdir(exist_ok=True) + (OUTPUT_DIR / "finetuned").mkdir(exist_ok=True) + + voice_prompt = torch.load( + VOICES_DIR / "fr-Spk0_man.pt", map_location=device, weights_only=False + ) + + # --- Baseline --- + print("=" * 60) + print("VIBEVOICE BASELINE") + print("=" * 60) + model, processor = load_model() + + for stem, text in TEXTS.items(): + print(f" [{stem}] {text[:50]}...") + audio = generate_sample(model, processor, text, voice_prompt) + if audio is not None: + sf.write(str(OUTPUT_DIR / "baseline" / f"{stem}.wav"), audio, SAMPLE_RATE) + print(f" OK ({len(audio)/SAMPLE_RATE:.1f}s)") + else: + print(" FAILED") + + # --- Finetuned --- + print("\n" + "=" * 60) + print("VIBEVOICE FINETUNED") + print("=" * 60) + + # Load finetuned tts_language_model weights + print(f"Loading finetuned weights from {FINETUNED_WEIGHTS}...") + ft_weights = load_file(str(FINETUNED_WEIGHTS)) + model.model.tts_language_model.load_state_dict(ft_weights) + print("Finetuned weights loaded") + + for stem, text in TEXTS.items(): + print(f" [{stem}] {text[:50]}...") + audio = generate_sample(model, processor, text, voice_prompt) + if audio is not None: + sf.write(str(OUTPUT_DIR / "finetuned" / f"{stem}.wav"), audio, SAMPLE_RATE) + print(f" OK ({len(audio)/SAMPLE_RATE:.1f}s)") + else: + print(" FAILED") + + # Copy originals + print("\nCopying original SIWIS audio...") + import shutil + (OUTPUT_DIR / "original").mkdir(exist_ok=True) + siwis_wavs = Path("/home/spice/speech/app/liquid-audio/french_finetuning/data/raw/siwis/SiwisFrenchSpeechSynthesisDatabase/wavs") + for stem in TEXTS: + src = list(siwis_wavs.rglob(f"{stem}.wav")) + if src: + shutil.copy2(src[0], OUTPUT_DIR / "original" / f"{stem}.wav") + print(f" {stem} copied") + + print("\nDone!") + + +if __name__ == "__main__": + main() diff --git a/comparisons/qwen3tts.log b/comparisons/qwen3tts.log new file mode 100644 index 0000000000000000000000000000000000000000..ca5e3020a2516b28e0742c0096c2a17f9e0dc10f --- /dev/null +++ b/comparisons/qwen3tts.log @@ -0,0 +1,87 @@ +/bin/sh: 1: sox: not found +SoX could not be found! + + If you do not have SoX, proceed here: + - - - http://sox.sourceforge.net/ - - - + + If you do (or think that you should) have SoX, double-check your + path variables. + + +******** +Warning: flash-attn is not installed. Will only run the manual PyTorch version. Please install flash-attn for faster inference. +******** + +============================================================ +QWEN3-TTS BASELINE +============================================================ + Fetching 4 files: 0%| | 0/4 [00:00