Skip to main content

A package for NeuCodec, based on xcodec2.

Project description

HuggingFace: Model, Distilled Model

Model Details

NeuCodec is a Finite Scalar Quantisation (FSQ) based 0.8kbps audio codec for speech tokenization. It takes advantage of the following features:

  • It uses both audio (BigCodec) and semantic (Wav2Vec2-BERT) encoders.
  • We make use of Finite Scalar Quantisation (FSQ) resulting in a single vector for the quantised output, which makes it ideal for downstream modeling with Speech Language Models.
  • At 50 tokens/sec and 16 bits per token, the overall bit-rate is 0.8kbps.
  • The codec takes in 16kHz input and outputs 24kHz using an upsampling decoder.

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

Get Started

Use the code below to get started with the model.

To install from pypi in a dedicated environment:

conda create -n neucodec python>3.9
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 NeuCodec
 
model = NeuCodec.from_pretrained("neuphonic/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 following data:

  • Emilia-YODAS
  • MLS
  • LibriTTS
  • Fleurs
  • CommonVoice
  • HUI
  • Additional proprietary set

All publically available data was covered by either the CC-BY-4.0 or CC0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neucodec-0.0.3.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neucodec-0.0.3-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file neucodec-0.0.3.tar.gz.

File metadata

  • Download URL: neucodec-0.0.3.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure

File hashes

Hashes for neucodec-0.0.3.tar.gz
Algorithm Hash digest
SHA256 78c52cc1311ffbbb0f7cb0b03f329933e90eaf00a905def26224b956dfb8aeea
MD5 883561fc584f647ce410b66013f040ce
BLAKE2b-256 f55fbf5c4fe08a30e78763fc07ed526bbbb156305fbb87cdbbf90d01d8cf3053

See more details on using hashes here.

File details

Details for the file neucodec-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: neucodec-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure

File hashes

Hashes for neucodec-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a3d16a05fd3620a450dcf535366ea06815fb6110b100ebb0034a37e7914deea5
MD5 4ea2a11f46ad72b959d4f97a418f6bc2
BLAKE2b-256 af4a5c84749450dd4c4d95696d500adccd37d966b46bb2ab86e1aae96acce4ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page