SAVRN
Search Contact SAVRN

Open-weight model · Speech recognition

wav2vec2-large-xlsr-53-th

by VISTEC-depa AI Research Institute of Thailand airesearch/wav2vec2-large-xlsr-53-th

Finetuning wav2vec2-large-xlsr-53 on Thai Common Voice 7.0 We finetune wav2vec2-large-xlsr-53 based on Fine-tuning Wav2Vec2 for English ASR using Thai examples of Common Voice Corpus 7.0.

Parameters
Context
Weights1.3 GB
Licensecc-by-sa-4.0
AccessOpen weights
Monthly Downloads1.5M

Model Card

By VISTEC-depa AI Research Institute of Thailand, published under cc-by-sa-4.0, revision 3155938c549b.

Finetuning wav2vec2-large-xlsr-53 on Thai Common Voice 7.0 We finetune wav2vec2-large-xlsr-53 based on Fine-tuning Wav2Vec2 for English ASR using Thai examples of Common Voice Corpus 7.0. The notebooks and scripts can be found in vistec-ai/wav2vec2-large-xlsr-53-th. The pretrained model and processor can be found at airesearch/wav2vec2-large-xlsr-53-th. Add syllabletokenize, wordtokenize (PyThaiNLP) and deepcut tokenizers to eval.py from robust-speech-event Common Voice Corpus 7.0](https://commonvoice.mozilla.org/en/datasets) contains 133 validated hours of Thai (255 total hours) at 5GB. We pre-tokenize with pythainlp.tokenize.wordtokenize. We preprocess the dataset using cleaning rules…

Read VISTEC-depa AI Research Institute of Thailand's full model card

Finetuning wav2vec2-large-xlsr-53 on Thai Common Voice 7.0

Read more on our blog

We finetune wav2vec2-large-xlsr-53 based on Fine-tuning Wav2Vec2 for English ASR using Thai examples of Common Voice Corpus 7.0. The notebooks and scripts can be found in vistec-ai/wav2vec2-large-xlsr-53-th. The pretrained model and processor can be found at airesearch/wav2vec2-large-xlsr-53-th.

robust-speech-event

Add syllable_tokenize, word_tokenize (PyThaiNLP) and deepcut tokenizers to eval.py from robust-speech-event

> python eval.py --model_id ./ --dataset mozilla-foundation/common_voice_7_0 --config th --split test --log_outputs --thai_tokenizer newmm/syllable/deepcut/cer

Eval results on Common Voice 7 "test":

WER PyThaiNLP 2.3.1 WER deepcut SER CER
Only Tokenization 0.9524% 2.5316% 1.2346% 0.1623%
Cleaning rules and Tokenization TBD TBD TBD TBD

Usage

#load pretrained processor and model
processor = Wav2Vec2Processor.from_pretrained("airesearch/wav2vec2-large-xlsr-53-th")
model = Wav2Vec2ForCTC.from_pretrained("airesearch/wav2vec2-large-xlsr-53-th")

#function to resample to 16_000
def speech_file_to_array_fn(batch, 
                            text_col="sentence", 
                            fname_col="path",
                            resampling_to=16000):
    speech_array, sampling_rate = torchaudio.load(batch[fname_col])
    resampler=torchaudio.transforms.Resample(sampling_rate, resampling_to)
    batch["speech"] = resampler(speech_array)[0].numpy()
    batch["sampling_rate"] = resampling_to
    batch["target_text"] = batch[text_col]
    return batch

#get 2 examples as sample input
test_dataset = test_dataset.map(speech_file_to_array_fn)
inputs = processor(test_dataset["speech"][:2], sampling_rate=16_000, return_tensors="pt", padding=True)

#infer
with torch.no_grad():
    logits = model(inputs.input_values,).logits

predicted_ids = torch.argmax(logits, dim=-1)

print("Prediction:", processor.batch_decode(predicted_ids))
print("Reference:", test_dataset["sentence"][:2])

>> Prediction: ['และ เขา ก็ สัมผัส ดีบุก', 'คุณ สามารถ รับทราบ เมื่อ ข้อความ นี้ ถูก อ่าน แล้ว']
>> Reference: ['และเขาก็สัมผัสดีบุก', 'คุณสามารถรับทราบเมื่อข้อความนี้ถูกอ่านแล้ว']

Datasets

Common Voice Corpus 7.0](https://commonvoice.mozilla.org/en/datasets) contains 133 validated hours of Thai (255 total hours) at 5GB. We pre-tokenize with pythainlp.tokenize.word_tokenize. We preprocess the dataset using cleaning rules described in notebooks/cv-preprocess.ipynb by @tann9949. We then deduplicate and split as described in ekapolc/Thai_commonvoice_split in order to 1) avoid data leakage due to random splits after cleaning in Common Voice Corpus 7.0 and 2) preserve the majority of the data for the training set. The dataset loading script is scripts/th_common_voice_70.py. You can use this scripts together with train_cleand.tsv, validation_cleaned.tsv and test_cleaned.tsv to have the same splits as we do. The resulting dataset is as follows:

DatasetDict({
    train: Dataset({
        features: ['path', 'sentence'],
        num_rows: 86586
    })
    test: Dataset({
        features: ['path', 'sentence'],
        num_rows: 2502
    })
    validation: Dataset({
        features: ['path', 'sentence'],
        num_rows: 3027
    })
})

Training

We fintuned using the following configuration on a single V100 GPU and chose the checkpoint with the lowest validation loss. The finetuning script is scripts/wav2vec2_finetune.py

# create model
model = Wav2Vec2ForCTC.from_pretrained(
    "facebook/wav2vec2-large-xlsr-53",
    attention_dropout=0.1,
    hidden_dropout=0.1,
    feat_proj_dropout=0.0,
    mask_time_prob=0.05,
    layerdrop=0.1,
    gradient_checkpointing=True,
    ctc_loss_reduction="mean",
    pad_token_id=processor.tokenizer.pad_token_id,
    vocab_size=len(processor.tokenizer)
)
model.freeze_feature_extractor()
training_args = TrainingArguments(
    output_dir="../data/wav2vec2-large-xlsr-53-thai",
    group_by_length=True,
    per_device_train_batch_size=32,
    gradient_accumulation_steps=1,
    per_device_eval_batch_size=16,
    metric_for_best_model='wer',
    evaluation_strategy="steps",
    eval_steps=1000,
    logging_strategy="steps",
    logging_steps=1000,
    save_strategy="steps",
    save_steps=1000,
    num_train_epochs=100,
    fp16=True,
    learning_rate=1e-4,
    warmup_steps=1000,
    save_total_limit=3,
    report_to="tensorboard"
)

Evaluation

We benchmark on the test set using WER with words tokenized by PyThaiNLP 2.3.1 and deepcut, and CER. We also measure performance when spell correction using TNC ngrams is applied. Evaluation codes can be found in notebooks/wav2vec2_finetuning_tutorial.ipynb. Benchmark is performed on test-unique split.

WER PyThaiNLP 2.3.1 WER deepcut CER
Kaldi from scratch 23.04 7.57
Ours without spell correction 13.634024 8.152052 2.813019
Ours with spell correction 17.996397 14.167975 5.225761
Google Web Speech API※ 13.711234 10.860058 7.357340
Microsoft Bing Speech API※ 12.578819 9.620991 5.016620
Amazon Transcribe※ 21.86334 14.487553 7.077562
NECTEC AI for Thai Partii API※ 20.105887 15.515631 9.551027

※ APIs are not finetuned with Common Voice 7.0 data

LICENSE

cc-by-sa 4.0

Ackowledgements

Configuration

Architecture
Wav2Vec2ForCTC
Layers
24
Hidden size
1,024
Feed-forward size
4,096
Attention heads
16
Vocabulary size
70
Stored precision
float32
Model type
wav2vec2

Identity and Version

Repository
airesearch/wav2vec2-large-xlsr-53-th
Publisher
VISTEC-depa AI Research Institute of Thailand
Task
Speech recognition
Modality
Audio
Library
transformers
Parameters
Not stated by the source
Languages
th
Revision
3155938c549b23eee16b1d4b55dcb161b7fe4bcf
First published
2022-03-02
Last updated
2022-03-23

Files and Weights

32 files, 1.3 GB in total. The weights are 5 files totalling 1.3 GB in bin, pt, pth.

Weights5 files · 1.3 GB
Configuration5 files · 57.5 KB
Tokenizer2 files · 943 B
Documentation1 file · 8.6 KB
Other18 files · 15.8 KB
Repository1 file · 737 B
Every file
FileTypeSizeSHA-256
pytorch_model.binWeights1.3 GB 54824f24eb41
rng_state.pthWeights15.6 KB 040892c8367e
scaler.ptWeights559 B eaad0a550aad
scheduler.ptWeights623 B bb118fee7b3c
training_args.binWeights2.7 KB 9b84fdc2b520
config.jsonConfiguration1.8 KB
eval.pyConfiguration5.5 KB
preprocessor_config.jsonConfiguration215 B
special_tokens_map.jsonConfiguration85 B
trainer_state.jsonConfiguration49.8 KB
README.mdDocumentation8.6 KB
robust-speech-event/.ipynb_checkpoints/log_mozilla-foundation_common_voice_7_0_th_test_predictions_cer-checkpoint.txtOther1.3 KB
robust-speech-event/.ipynb_checkpoints/log_mozilla-foundation_common_voice_7_0_th_test_predictions_deepcut-checkpoint.txtOther1.0 KB
robust-speech-event/.ipynb_checkpoints/log_mozilla-foundation_common_voice_7_0_th_test_predictions_newmm-checkpoint.txtOther1.0 KB
robust-speech-event/.ipynb_checkpoints/log_mozilla-foundation_common_voice_7_0_th_test_targets_cer-checkpoint.txtOther1.3 KB
robust-speech-event/.ipynb_checkpoints/log_mozilla-foundation_common_voice_7_0_th_test_targets_deepcut-checkpoint.txtOther1.0 KB
robust-speech-event/.ipynb_checkpoints/log_mozilla-foundation_common_voice_7_0_th_test_targets_newmm-checkpoint.txtOther1.0 KB
robust-speech-event/log_mozilla-foundation_common_voice_7_0_th_test_predictions_cer.txtOther1.3 KB
robust-speech-event/log_mozilla-foundation_common_voice_7_0_th_test_predictions_deepcut.txtOther1.0 KB
robust-speech-event/log_mozilla-foundation_common_voice_7_0_th_test_predictions_newmm.txtOther1.0 KB
robust-speech-event/log_mozilla-foundation_common_voice_7_0_th_test_predictions_syllable.txtOther1.1 KB
robust-speech-event/log_mozilla-foundation_common_voice_7_0_th_test_targets_cer.txtOther1.3 KB
robust-speech-event/log_mozilla-foundation_common_voice_7_0_th_test_targets_deepcut.txtOther1.0 KB
robust-speech-event/log_mozilla-foundation_common_voice_7_0_th_test_targets_newmm.txtOther1.0 KB
robust-speech-event/log_mozilla-foundation_common_voice_7_0_th_test_targets_syllable.txtOther1.1 KB
robust-speech-event/mozilla-foundation_common_voice_7_0_th_test_eval_results_cer.txtOther52 B
robust-speech-event/mozilla-foundation_common_voice_7_0_th_test_eval_results_deepcut.txtOther52 B
robust-speech-event/mozilla-foundation_common_voice_7_0_th_test_eval_results_newmm.txtOther50 B
robust-speech-event/mozilla-foundation_common_voice_7_0_th_test_eval_results_syllable.txtOther52 B
.gitattributesRepository737 B
tokenizer_config.jsonTokenizer181 B
vocab.jsonTokenizer762 B

License and Download

License
cc-by-sa-4.0
Access
Open weights, no gate
Download size
1.3 GB
Download from VISTEC-depa AI Research Institute of Thailand

Released by VISTEC-depa AI Research Institute of Thailand through its official repository on Hugging Face. Read the license.

Built From

  • Trained on (disclosed) common_voice

Evaluations

Each result is shown as reported, with the conditions its reporter stated. None is a SAVRN measurement. A comparison lines two results up only when their configuration, unit and setup are all stated and identical.

BenchmarkConditionsResultReported byRevisionDate
Common Voice 7 Task Automatic Speech RecognitionMetric Test CERComparison conditions not established 0.1623 airesearch
Publisher reported
Evaluated revision not stated
Common Voice 7 Task Automatic Speech RecognitionMetric Test SERComparison conditions not established 1.2346 airesearch
Publisher reported
Evaluated revision not stated
Common Voice 7 Task Automatic Speech RecognitionMetric Test WERComparison conditions not established 0.9524 airesearch
Publisher reported
Evaluated revision not stated

Memory Requirements

PrecisionWeights in memory
As published1.3 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About wav2vec2-large-xlsr-53-th

Can I use wav2vec2-large-xlsr-53-th commercially?

Yes. wav2vec2-large-xlsr-53-th is released under Creative Commons Attribution-ShareAlike 4.0. CC BY-SA 4.0 permits sharing and adapting, including commercially, with credit to the creator, and requires adaptations to be released under the same license.

Similar Models

Model · Speech recognition

wav2vec2-large-xlsr-53-japanese

Jonatas Grosman

Fine-tuned facebook/wav2vec2-large-xlsr-53 on Japanese using the train and validation splits of Common Voice 6.1, CSS10 and JSUT. When using this model, make sure that your speech input is sampled at 16kHz. This model has been fine-tuned thanks to the GPU credits generously given by the OVHcloud:) The script used for training can be found here: https://github.com/jonatasgrosman/wav2vec2-sprint The model can be used directly (without a language model) as follows... Using the HuggingSound library: The model can be evaluated as follows on the Japanese test data of Common Voice. In the table below I report the Word Error Rate (WER) and the Character Error Rate (CER) of the model. I ran the…

Open weights apache-2.0 transformers

Model · Speech recognition

whisperkit-coreml

Argmax

WhisperKit is part of Argmax OSS, an On-device Speech AI SDK for Apple Silicon: https://github.com/argmaxinc/argmax-oss-swift Check out the WhisperKit paper and presentation from ICML 2025: https://icml.cc/virtual/2025/47854 For real-time transcription with speakers and custom vocabulary, check out Argmax Pro SDK: https://www.argmaxinc.com/blog/argmax-sdk-2

Open weights mit whisperkit

Model · Speech recognition

speaker-diarization-3.1

Pyannote

Using this open-source model in production? Consider switching to pyannoteAI for better and faster options. This pipeline is the same as pyannote/speaker-diarization-3.0 except it removes the problematic use of onnxruntime. Both speaker segmentation and embedding now run in pure PyTorch. This should ease deployment and possibly speed up inference. It requires pyannote.audio version 3.1 or higher. It ingests mono audio sampled at 16kHz and outputs speaker diarization as an Annotation instance: - stereo or multi-channel audio files are automatically downmixed to mono by averaging the channels. - audio files sampled at a different rate are resampled to 16kHz automatically upon loading. 1.…

Access requested at publisher mit pyannote-audio

Fine-tuned facebook/wav2vec2-large-xlsr-53 on Portuguese using the train and validation splits of Common Voice 6.1. When using this model, make sure that your speech input is sampled at 16kHz. This model has been fine-tuned thanks to the GPU credits generously given by the OVHcloud:) The script used for training can be found here: https://github.com/jonatasgrosman/wav2vec2-sprint The model can be used directly (without a language model) as follows... Using the HuggingSound library: 1. To evaluate on mozilla-foundation/commonvoice60 with split test 2. To evaluate on speech-recognition-community-v2/devdata If you want to cite this model you can use this

Open weights apache-2.0 transformers

Model · Speech recognition

speaker-diarization-community-1

Pyannote

This pipeline ingests mono audio sampled at 16kHz and outputs speaker diarization. - stereo or multi-channel audio files are automatically downmixed to mono by averaging the channels. - audio files sampled at a different rate are resampled to 16kHz automatically upon loading. The main improvements brought by Community-1 are: - improved speaker assignment and counting - simpler reconciliation with transcription timestamps with exclusive speaker diarization - easy offline use (i.e. without internet connection) - (optionally) hosted on pyannoteAI cloud 1. pip install pyannote.audio 3. Create access token at hf.co/settings/tokens. Out of the box, Community-1 is much better than…

Access requested at publisher cc-by-4.0 pyannote-audio

Model · Speech recognition

wav2vec2-large-xlsr-53-russian

Jonatas Grosman

Fine-tuned facebook/wav2vec2-large-xlsr-53 on Russian using the train and validation splits of Common Voice 6.1 and CSS10. When using this model, make sure that your speech input is sampled at 16kHz. This model has been fine-tuned thanks to the GPU credits generously given by the OVHcloud:) The script used for training can be found here: https://github.com/jonatasgrosman/wav2vec2-sprint The model can be used directly (without a language model) as follows... Using the HuggingSound library: 1. To evaluate on mozilla-foundation/commonvoice60 with split test 2. To evaluate on speech-recognition-community-v2/devdata If you want to cite this model you can use this

Open weights apache-2.0 transformers