Skip to main content

A package for NeuCodec, based on xcodec2.

Project description

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.2.tar.gz (17.9 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.2-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neucodec-0.0.2.tar.gz
  • Upload date:
  • Size: 17.9 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.2.tar.gz
Algorithm Hash digest
SHA256 b28d693ce30d0dc4ff1f9fb429379327b54574001114a7484630293f6ff06977
MD5 8a856f564eb4b30897d07d3ad608c3a5
BLAKE2b-256 3ca6b07dbeda6df387fb10e1b51220dba4817d8876bf6d69e5819e50c8af3800

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neucodec-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 23.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 366f01969c74834fb7869a76f3f0797026dfca0772c38263bd697ff1d98bc009
MD5 cd9122b795bbff0a125e1bad907ea5cf
BLAKE2b-256 719055d5c56bc2bd15acf8a8425adf1e62968915fd46d3db1d962e2ab1293747

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