Automatic Speech Recognition
Transformers
Safetensors
Welsh
English
wav2vec2
Inference Endpoints
DewiBrynJones's picture
Update README.md
8aaa6d9 verified
|
raw
history blame
2.01 kB
metadata
license: apache-2.0
base_model: facebook/wav2vec2-large-xlsr-53
metrics:
  - wer
datasets:
  - techiaith/commonvoice_16_1_en_cy
  - techiaith/banc-trawsgrifiadau-bangor
language:
  - cy
  - en
pipeline_tag: automatic-speech-recognition

wav2vec2-xlsr-53-ft-cy-en-withlm

This model is a version of facebook/wav2vec2-large-xlsr-53 that has been fined-tuned with a custom bilingual datasets derived from the Welsh and English data releases of Mozilla Foundation's Commonvoice project. See : techiaith/commonvoice_16_1_en_cy.

In addition, this model also includes a single KenLM n-gram model trained with balanced collections of Welsh and English texts from OSCAR This avoids the need for any language detection for determining whether to use a Welsh or English n-gram models during CTC decoding.

Usage

The wav2vec2-xlsr-53-ft-cy-en-withlm model can be used directly as follows:

import torch
import torchaudio
import librosa

from transformers import Wav2Vec2ForCTC, Wav2Vec2ProcessorWithLM

processor = Wav2Vec2ProcessorWithLM.from_pretrained("techiaith/wav2vec2-xlsr-53-ft-cy-en-withlm")
model = Wav2Vec2ForCTC.from_pretrained("techiaith/wav2vec2-xlsr-53-ft-cy-en-withlm")

audio, rate = librosa.load(<path/to/audio_file>, sr=16000)

inputs = processor(audio, sampling_rate=16_000, return_tensors="pt", padding=True)

with torch.no_grad():
  tlogits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits

print("Prediction: ", processor.batch_decode(tlogits.numpy(), beam_width=10).text[0].strip())

Usage with a pipeline is even simpler...

from transformers import pipeline

transcriber = pipeline("automatic-speech-recognition", model="techiaith/wav2vec2-xlsr-53-ft-cy-en-withlm")

def transcribe(audio):
    return transcriber(audio)["text"]

transcribe(<path/or/url/to/any/audiofile>)