# wav2letter++

> Facebook AI Research's C++ speech recognition toolkit, kept as research recipes and pre-trained models

- Category: Multimodal Generation / Audio, Music & Voice
- Language: C++
- Licence: BSD
- Repository: https://github.com/flashlight/wav2letter
- Canonical page: https://ai-tldr.dev/tools/wav2letter/
- Updated: 2020-12-28

## In short

wav2letter++ is the automatic speech recognition (ASR) toolkit from Facebook AI Research, written in C++ and described in the arXiv paper "wav2letter++: The Fastest Open-source Speech Recognition System" (arXiv:1812.07625). It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in C++ and licensed BSD.

## Overview

wav2letter++ is the automatic speech recognition (ASR) toolkit from Facebook AI Research, written in C++ and described in the arXiv paper "wav2letter++: The Fastest Open-source Speech Recognition System" (arXiv:1812.07625). It trains end-to-end acoustic models that turn audio straight into letters or word pieces, then decodes them with a beam search and an optional language model.

The project has a clearly stated status: its README says wav2letter was moved and consolidated into Flashlight, as Flashlight's ASR application, and that future wav2letter development happens there. The pre-consolidation code is preserved as the v0.2 release (December 2020), which builds against Flashlight v0.2, and the original Lua version lives on the wav2letter-lua branch.

What the repository still offers is its research recipes: training, decoding and data-preparation setups plus pre-trained models for FAIR speech papers, including streaming ConvNets, the 2019 end-to-end ASR architecture study, self-training, lexicon-free recognition, sequence-to-sequence models with time-depth separable convolutions and the original Wav2Letter ConvNet. The README asks that exact reproduction of those results use Flashlight 0.3.2 or earlier.

## What it does

- Recipes with pre-trained models that reproduce FAIR ASR papers, from the original Wav2Letter ConvNet to streaming ConvNets and semi-supervised self-training
- Data-preparation scripts for common speech corpora, including LibriSpeech, WSJ, TIMIT, AMI and Multilingual LibriSpeech (MLS)
- Acoustic-model setups covering ResNet, TDS and Transformer architectures trained with CTC or Seq2Seq criteria, as studied in the sota/2019 recipe
- A streaming model with 500 ms of future context, trained on 1k hours of LibriSpeech plus 57k hours of unlabelled LibriVox audio
- Word-piece and word-level language-model recipes (n-gram, ConvLM, Transformer) for beam-search decoding and rescoring
- Built with CMake on top of Flashlight and ArrayFire; the older wav2letter-lua implementation is kept on its own branch

## Getting started

The repository builds its recipes on top of Flashlight. Per the README, Flashlight must be installed from its 0.3 branch with the ASR application; to build the pre-consolidation toolkit itself, check out the wav2letter v0.2 release, which pairs with Flashlight v0.2.

1. Install Flashlight with the ASR app

   Install Flashlight from its 0.3 branch (https://github.com/flashlight/flashlight/tree/0.3) with the ASR application enabled, following Flashlight's own build instructions.

2. Clone the repository

```bash
git clone https://github.com/flashlight/wav2letter.git
cd wav2letter
```

3. Build the recipes

   If Flashlight or ArrayFire were installed under a custom CMAKE_INSTALL_PREFIX, add -Dflashlight_DIR=[PREFIX]/usr/share/flashlight/cmake/ -DArrayFire_DIR=[PREFIX]/usr/share/ArrayFire/cmake to the cmake call.

```bash
mkdir build && cd build
cmake .. && make -j8
```

4. Prepare a dataset

   Each corpus under data/ has its own preparation script. For LibriSpeech, run this from data/librispeech, replacing [...] with the directory where audio and text should be stored.

```bash
python3 prepare.py --dst [...]
```

5. Follow a paper recipe

   Pick a directory under recipes/ (for example streaming_convnets or sota/2019). Each one documents its dependencies, flags files, pre-trained models and the training and decoding steps for that paper.

## When to use it

- Reproducing or benchmarking against FAIR's published speech recognition results on LibriSpeech and related corpora
- Starting from a pre-trained ConvNet, TDS or Transformer acoustic model instead of training an ASR system from scratch
- Studying how streaming, lexicon-free or semi-supervised ASR recipes are set up before moving to Flashlight's ASR application
- Maintaining an existing wav2letter v0.2 deployment that predates the consolidation into Flashlight

## Version history

- 2020-12-28 v0.2: Final pre-consolidation release of wav2letter, built against Flashlight v0.2; later development continues in Flashlight's ASR application.
- 2018-12-21 v0.1: Initial release of the wav2letter++ C++ speech recognition toolkit.
