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.1.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.1-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neucodec-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8fcd04083b8c18b1323021e21bbd94712923882eb1d9311e4d4ac9f9095aaf6e
MD5 dc2f5a582d52039c173623fb332185ee
BLAKE2b-256 67f5f076c8ce41278b429250fe3665218cd6baeefe02403ac159dda4012fbbb3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neucodec-0.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3206e19df2bccdefe8dd50fa0e1205fadb9ff011e2bd85a909895ddf89ffc259
MD5 3b33b10f4361ffcb87ba9ebade4c9268
BLAKE2b-256 e8a65d4b304bcd81e846ebda071dc5b431ebe7a5f3b5c876cbc5e7d5c2dec439

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