neuphonic/distill-neucodec

🤗 Hugging Face 来源audio-to-audioapache-2.06.9 GBother✓ 1 个校验和今天更新
帮助这个模型通过 Pirate Face 分发

模型卡、文件列表和校验和已在此收录。如果你持有文件并有权分享,可以提交种子,让其他人从节点下载。

获取来源文件需要 Hugging Face 批准。
为此模型做种

Model Details

Distill-NeuCodec is a version of NeuCodec with a compatible, distilled encoder.

The distilled encoder is 10x smaller in parameter count and uses ~7.5x less MACs at inference time.

The distilled model makes the following adjustments to the model:

Our work is largely based on extending the work of X-Codec2.0 and SQCodec.

Get Started

Use the code below to get started with the model.

To install from pypi in a dedicated environment, using Python 3.10 or above:

conda create -n neucodec python=3.10
conda activate neucodec
pip install neucodec

Then, to use in python:

import librosa
import torch
import torchaudio
from torchaudio import transforms as T
from neucodec import DistillNeuCodec
 
model = DistillNeuCodec.from_pretrained("neuphonic/distill-neucodec")
model.eval().cuda()   
 
y, sr = torchaudio.load(librosa.ex("libri1"))
if sr != 16_000:
    y = T.Resample(sr, 16_000)(y)[None, ...] # (B, 1, T_16)

with torch.no_grad():
    fsq_codes = model.encode_code(y)
    # fsq_codes = model.encode_code(librosa.ex("libri1")) # or directly pass your filepath!
    print(f"Codes shape: {fsq_codes.shape}")  
    recon = model.decode_code(fsq_codes).cpu() # (B, 1, T_24)

torchaudio.save("reconstructed.wav", recon[0, :, :], 24_000)

Training Details

The model was trained using the same data as the full model, with an additional distillation loss (MSE between distilled and original encoder ouputs).