File size: 2,247 Bytes
0ff9d37
0b704d8
 
 
 
 
 
 
 
0ff9d37
 
 
 
0b704d8
 
0ff9d37
0b704d8
 
 
 
 
0ff9d37
0b704d8
 
 
0ff9d37
0b704d8
 
 
 
 
 
 
 
 
9fcacec
 
 
 
 
 
 
 
 
 
 
 
 
0b704d8
 
9fcacec
 
 
 
0b704d8
 
 
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
---
license: other
license_name: per-codec
license_link: https://huggingface.co/BricksDisplay/codec.cpp-gguf#license
tags:
- codec.cpp
- gguf
- audio
- neural-audio-codec
---

# codec.cpp GGUFs

Neural audio codecs for [codec.cpp](https://github.com/mybigday/codec.cpp): turn
speech into discrete tokens and back, offline on CPU or GPU.

| Codec | Sample rate | Token rate | Files |
|---|---|---|---|
| [IBM DAC.speech v1.0](https://huggingface.co/ibm-research/DAC.speech.v1.0) | 24 kHz | 75 frames/s | `ibm-research--DAC.speech*.gguf` |
| [NVIDIA NeMo Nano Codec](https://huggingface.co/nvidia/nemo-nano-codec-22khz-0.6kbps-12.5fps) | 22.05 kHz | 12.5 frames/s (0.6 kbps) | `nemo-nano-codec-22khz-0.6kbps-12.5fps*.gguf` |
| [WavTokenizer large (speech)](https://huggingface.co/novateur/WavTokenizer-large-speech-75token) | 24 kHz | 75 tokens/s | `wavtokenizer-large-speech-75tokens*.gguf` |

Each codec comes in several precisions: the file without a suffix is F16
(recommended), `-F32` is full precision, `-Q8_0` / `-Q5_K_M` / `-Q4_K_M` are
smaller and faster at some quality cost.

## Run

```bash
hf download BricksDisplay/codec.cpp-gguf ibm-research--DAC.speech.gguf --local-dir codecs

./build/codec-cli encode --model codecs/ibm-research--DAC.speech.gguf --in speech.wav --out codes.npy
./build/codec-cli decode --model codecs/ibm-research--DAC.speech.gguf --codes codes.npy --out decoded.wav
```

Python (`pip install .` in a codec.cpp checkout; see
[python/README.md](https://github.com/mybigday/codec.cpp/blob/main/python/README.md)):

```python
import codec_cpp, soundfile as sf

ctx = codec_cpp.Model("codecs/ibm-research--DAC.speech.gguf").context()
pcm, sr = sf.read("speech.wav", dtype="float32")
codes = ctx.encode(pcm, sr)          # int32 (n_frames, n_q)
audio, sr = ctx.decode(codes)
```

Build instructions and GPU flags are in the
[codec.cpp README](https://github.com/mybigday/codec.cpp).

These codecs are also the audio side of TTS models: there a llama.cpp LM
backbone writes the codes and codec.cpp turns them into audio (see the
`*-GGUF` TTS repos of this organization).

## License

Each codec keeps its original license: DAC.speech CDLA-Permissive-2.0, NeMo Nano Codec the NVIDIA Open Model License, WavTokenizer MIT.