---
title: "Fine-Tune XLSR-Wav2Vec2 for low-resource ASR with 🤗 Transformers"
description: "XLS-R, the multilingual successor to Wav2Vec2 pre-trained on roughly half a million hours of audio in 128 languages, can be fine-tuned for speech recognition by adding a linear layer on top and training with Connectionist Temporal Classification (CTC)."
url: "https://swe.quest/articles/fine-tune-xlsr-wav2vec2-for-low-resource-asr-with-transformers-67aead681013ec16"
canonical: "https://huggingface.co/blog/fine-tune-xlsr-wav2vec2"
source: "Hugging Face"
published: "2021-11-15"
difficulty: "medium"
kind: "How-to"
reading_minutes: 23
tags: ["speech-audio","model-training","python"]
---

# Fine-Tune XLSR-Wav2Vec2 for low-resource ASR with 🤗 Transformers

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2021-11-15, 23 min read, How-to. Original: [https://huggingface.co/blog/fine-tune-xlsr-wav2vec2](https://huggingface.co/blog/fine-tune-xlsr-wav2vec2)

## Summary

XLS-R, the multilingual successor to Wav2Vec2 pre-trained on roughly half a million hours of audio in 128 languages, can be fine-tuned for speech recognition by adding a linear layer on top and training with Connectionist Temporal Classification (CTC). The walkthrough fine-tunes the 300M-parameter checkpoint on about 4 hours of Turkish Common Voice data using 🤗 Transformers and Datasets. It covers text normalization (stripping punctuation, lowercasing, replacing hatted characters), building a character-level vocabulary with word-delimiter, unknown and CTC blank/padding tokens, and setting up the Wav2Vec2CTCTokenizer and feature extractor, with word error rate as the evaluation metric.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Speech & audio](https://swe.quest/tags/speech-audio.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- PyTorch basics
- Transformer models
- CTC loss basics

## Keywords

XLS-R, Wav2Vec2, Hugging Face Transformers, Common Voice, CTC, Wav2Vec2CTCTokenizer, WER

## Related posts

- [Fine-Tune Wav2Vec2 for English ASR in Hugging Face with 🤗 Transformers](https://swe.quest/articles/fine-tune-wav2vec2-for-english-asr-in-hugging-face-with-transformers-3965ec4df26fb19a.md): Hugging Face · 2021-03-12 · Medium · 24 min read · Speech & audio, Model training, Python
  Wav2Vec2, pretrained with a contrastive masked objective on 50k+ hours of unlabeled speech, can be fine-tuned with CTC on small labeled datasets for end-to-end English ASR without a language model.
- [Fine-Tune Whisper For Multilingual ASR with 🤗 Transformers](https://swe.quest/articles/fine-tune-whisper-for-multilingual-asr-with-transformers-718acb121632ac73.md): Hugging Face · 2022-11-03 · Medium · 25 min read · Speech & audio, Model training, Python
  Whisper, OpenAI's encoder-decoder ASR model pre-trained on 680,000 hours of labelled audio, can be fine-tuned for a low-resource language with Hugging Face Transformers using only about 8 hours of data.
- [Fine-Tune W2V2-Bert for low-resource ASR with 🤗 Transformers](https://swe.quest/articles/fine-tune-w2v2-bert-for-low-resource-asr-with-transformers-c92730274dccb3a7.md): Hugging Face · 2024-01-19 · Medium · 26 min read · Speech & audio, Model training, Python
  Wav2Vec2-BERT (facebook/w2v-bert-2.0), a 580M-parameter audio model pre-trained on 4.5M hours across 143+ languages, can be fine-tuned with CTC for ASR in low-resource languages using Hugging Face Transformers, demonstrated on ~14h of Mongolian Common Voice 16.0 data.
- [Fine-Tune MMS Adapter Models for low-resource ASR](https://swe.quest/articles/fine-tune-mms-adapter-models-for-low-resource-asr-870510273b1ec1b7.md): Hugging Face · 2023-06-19 · Medium · 27 min read · Speech & audio, Model training, Python
  MMS adapter training fine-tunes only about 2.5M language-specific adapter weights on Meta's mms-1b-all checkpoint, reaching low word error rates after 10-20 minutes of training on small datasets.
- [Speech Synthesis, Recognition, and More With SpeechT5](https://swe.quest/articles/speech-synthesis-recognition-and-more-with-speecht5-f8b2cd78391a59c0.md): Hugging Face · 2023-02-08 · Medium · 9 min read · Speech & audio, Machine learning, Python
  SpeechT5, Microsoft Research Asia's unified speech model, is now in 🤗 Transformers.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
