ankit1089sony's picture
history blame
5.42 kB
  - multilingual
  - fr
  - de
  - es
  - ca
  - it
  - ru
  - zh
  - pt
  - fa
  - et
  - mn
  - nl
  - tr
  - ar
  - sv
  - lv
  - sl
  - ta
  - ja
  - id
  - cy
  - en
  - common_voice
  - multilingual_librispeech
  - covost2
  - speech
  - xls_r
  - automatic-speech-recognition
  - xls_r_translation
pipeline_tag: automatic-speech-recognition
license: apache-2.0
  - example_title: Swedish
  - example_title: Arabic
    src: >-
  - example_title: Russian
    src: >-
  - example_title: German
    src: >-
  - example_title: French
    src: >-
  - example_title: Indonesian
    src: >-
  - example_title: Italian
    src: >-
  - example_title: Japanese
    src: >-
  - example_title: Mongolian
    src: >-
  - example_title: Dutch
    src: >-
  - example_title: Russian
    src: >-
  - example_title: Turkish
    src: >-
  - example_title: Catalan
    src: >-
  - example_title: English
    src: >-
  - example_title: Dutch
    src: >-


Facebook's Wav2Vec2 XLS-R fine-tuned for Speech Translation.

model image

This is a SpeechEncoderDecoderModel model. The encoder was warm-started from the facebook/wav2vec2-xls-r-1b checkpoint and the decoder from the facebook/mbart-large-50 checkpoint. Consequently, the encoder-decoder model was fine-tuned on 21 {lang} -> en translation pairs of the Covost2 dataset.

The model can translate from the following spoken languages {lang} -> en (English):

{fr, de, es, ca, it, ru, zh-CN, pt, fa, et, mn, nl, tr, ar, sv-SE, lv, sl, ta, ja, id, cy} -> en

For more information, please refer to Section 5.1.2 of the official XLS-R paper.



The model can be tested directly on the speech recognition widget on this model card! Simple record some audio in one of the possible spoken languages or pick an example audio file to see how well the checkpoint can translate the input.


As this a standard sequence to sequence transformer model, you can use the generate method to generate the transcripts by passing the speech features to the model.

You can use the model directly via the ASR pipeline

from datasets import load_dataset
from transformers import pipeline

# replace following lines to load an audio file of your choice
librispeech_en = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
audio_file = librispeech_en[0]["file"]

asr = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-xls-r-1b-21-to-en", feature_extractor="facebook/wav2vec2-xls-r-1b-21-to-en")

translation = asr(audio_file)

or step-by-step as follows:

import torch
from transformers import Speech2Text2Processor, SpeechEncoderDecoderModel
from datasets import load_dataset

model = SpeechEncoderDecoderModel.from_pretrained("facebook/wav2vec2-xls-r-1b-21-to-en")
processor = Speech2Text2Processor.from_pretrained("facebook/wav2vec2-xls-r-1b-21-to-en")

ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")

inputs = processor(ds[0]["audio"]["array"], sampling_rate=ds[0]["audio"]["array"]["sampling_rate"], return_tensors="pt")
generated_ids = model.generate(input_ids=inputs["input_features"], attention_mask=inputs["attention_mask"])
transcription = processor.batch_decode(generated_ids)

Results {lang} -> en

See the row of XLS-R (1B) for the performance on Covost2 for this model.

results image

More XLS-R models for {lang} -> en Speech Translation