textless-lib: a Library for Textless Spoken Language Processing

Eugene Kharitonov, Jade Copet, Kushal Lakhotia, Tu Anh Nguyen, Paden Tomasello, Ann Lee, Ali Elkahky, Wei-Ning Hsu, Abdelrahman Mohamed, Emmanuel Dupoux, Yossi Adi

Abstract

Eugene Kharitonov, Jade Copet, Kushal Lakhotia, Tu Anh Nguyen, Paden Tomasello, Ann Lee, Ali Elkahky, Wei-Ning Hsu, Abdelrahman Mohamed, Emmanuel Dupoux, Yossi Adi. Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies: System Demonstrations.

2022.

Introduction

Traditional Natural Language Processing (NLP) has long been tethered to the written word. However, this reliance on text creates significant barriers. Most of the world's languages lack a standardized writing system, and even for high-resource languages, text is a "lossy" medium that discards crucial acoustic information like prosody, emotion, and speaker identity.

"Textless" Spoken Language Modeling (SLM) offers a solution by learning linguistic structures directly from raw audio. While research in this area, such as the Generative Spoken Language Modeling (GSLM) pipeline, has grown rapidly, the technical barrier to entry remains high. Researchers often face a fragmented ecosystem of scripts and specialized checkpoints. To address this, Meta AI researchers developed textless-lib, a unified PyTorch library designed to make textless speech research accessible to the broader NLP community.

The Textless Pipeline

The textless-lib framework formalizes the spoken language processing pipeline into three distinct stages:

  1. Speech-to-Units (S2U): Raw audio is processed through a self-supervised encoder (e.g., HuBERT or CPC) to generate continuous representations. These are then quantized via k-means into discrete "pseudo-units," effectively creating a learned alphabet for speech.
  2. Unit-to-Units (U2U): These discrete units are treated as tokens, allowing standard NLP architectures like Transformers to perform tasks such as language modeling or translation.
  3. Units-to-Speech (U2S): A vocoder converts the discrete units back into a high-fidelity waveform.
The textless-lib encoder pipeline, featuring pitch extraction, self-supervised representation (HuBERT), k-means quantization, and run-length encoding.

A key contribution of the library is its high-level API. The SpeechEncoder class streamlines feature extraction, pitch alignment, and "deduplication"—a process that collapses repeated units to optimize storage and processing. Furthermore, the QuantizeDataset wrapper facilitates efficient multi-GPU preprocessing, removing a common bottleneck in large-scale speech research.

Quantization as a Linguistic Filter

A core insight of the research is the role of quantization as a feature bottleneck. While continuous features from models like HuBERT are highly effective at identifying speaker identity, the process of quantizing them into a limited vocabulary (e.g., 50 to 500 units) acts as a filter.

Speaker probing accuracy drops significantly after quantization, indicating that discrete units capture linguistic content while filtering out speaker identity.

As shown in the experimental results, continuous HuBERT features can identify a speaker with 99% accuracy. However, when quantized to just 50 units, this accuracy plummets to 11%. This suggests that the discrete units successfully capture the core linguistic content ("what" is said) while discarding the speaker-specific nuances ("how" it is said), achieving a form of speaker-invariant representation.

Compression and Resynthesis

By representing speech as a sequence of discrete integers, textless-lib enables extreme speech compression. The library allows researchers to explore the trade-off between bitrate and audio quality (measured by Word Error Rate, or WER). For example, using a vocabulary of 200 units achieves a bitrate of approximately 210.6 bit/s with a WER of 7.9. At the extreme end, a 50-unit vocabulary can reach bitrates as low as 125 bit/s, though the WER increases to 24.2.

Conclusion and Future Directions

textless-lib provides a robust foundation for the next generation of speech-centric AI. By treating speech as "pseudo-text," it opens the door for applying the full suite of NLP tools—from GPT-style generation to machine translation—directly to audio.

While the current release focuses on the encoding and decoding interfaces using vocoders like Tacotron2 and WaveGlow, future iterations aim to integrate more advanced models like HiFi-GAN for improved audio quality. The team also plans to expand the library's scope to include end-to-end spoken dialogue systems and speech-to-speech translation tasks.

Summary updated

BibTeX
@misc{kharitonov2022textless,
  author = {Eugene Kharitonov and Jade Copet and Kushal Lakhotia and Tu Anh Nguyen and Paden Tomasello and Ann Lee and Ali Elkahky and Wei-Ning Hsu and Abdelrahman Mohamed and Emmanuel Dupoux and Yossi Adi},
  title = {{textless-lib: a Library for Textless Spoken Language Processing}},
  year = {2022},
  eprint = {2202.07359},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2202.07359},
}
Figure