README: self-contained inference quickstart
Browse files
README.md
CHANGED
|
@@ -25,6 +25,36 @@ NeuCodec, so this model is a drop-in higher-fidelity decoder.
|
|
| 25 |
- **Trainable:** decoder only (GAN: multi-period + spec discriminators; losses: multi-res mel + STFT + feature-matching + adversarial)
|
| 26 |
- **Frozen:** w2v-BERT semantic encoder, acoustic `CodecEnc`, `fc_prior`/`fc_post_a`, FSQ codebook
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
## 🔗 Source code
|
| 29 |
|
| 30 |
Training pipeline, configs and benchmarks:
|
|
|
|
| 25 |
- **Trainable:** decoder only (GAN: multi-period + spec discriminators; losses: multi-res mel + STFT + feature-matching + adversarial)
|
| 26 |
- **Frozen:** w2v-BERT semantic encoder, acoustic `CodecEnc`, `fc_prior`/`fc_post_a`, FSQ codebook
|
| 27 |
|
| 28 |
+
## Inference (self-contained)
|
| 29 |
+
|
| 30 |
+
Everything needed to run inference is **in this repo** — the `neucodec/` package and
|
| 31 |
+
`infer_widecodec.py`. No other source code required.
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
pip install torch transformers huggingface_hub local-attention einops librosa soundfile
|
| 35 |
+
huggingface-cli login # if this repo is private (or export HF_TOKEN=hf_...)
|
| 36 |
+
|
| 37 |
+
huggingface-cli download Scicom-intl/WideCodec --local-dir WideCodec
|
| 38 |
+
cd WideCodec
|
| 39 |
+
python infer_widecodec.py --input my.wav --out-dir out # one file
|
| 40 |
+
python infer_widecodec.py --input folder/ --out-dir out # a directory
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
Or load it directly in Python:
|
| 44 |
+
|
| 45 |
+
```python
|
| 46 |
+
import sys; sys.path.insert(0, "WideCodec") # the downloaded repo dir
|
| 47 |
+
import torch, librosa
|
| 48 |
+
from neucodec import NeuCodec
|
| 49 |
+
|
| 50 |
+
model = NeuCodec._from_pretrained(model_id="Scicom-intl/WideCodec", decoder_depth=20).eval().cuda()
|
| 51 |
+
wav16, _ = librosa.load("my.wav", sr=16000, mono=True) # encoder ingests 16 kHz mono
|
| 52 |
+
x = torch.from_numpy(wav16).float().view(1, 1, -1).cuda()
|
| 53 |
+
with torch.no_grad():
|
| 54 |
+
codes = model.encode_code(x) # frozen FSQ codes — 0.8 kbps, 50 tok/s
|
| 55 |
+
wav44 = model.decode_code(codes) # 44.1 kHz reconstruction
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
## 🔗 Source code
|
| 59 |
|
| 60 |
Training pipeline, configs and benchmarks:
|