Table of Contents
Click to expand
Model Description
This is a HuBERT Base model pre-trained using 1,778 hours of Catalan speech data.
The model architecture is the same as the
original HuBERT Base model, which contains 12 transformer layers.
Pre-training was done by
Barcelona Supercomputing Center.
Intended Uses and Limitations
This pre-trained model generates Speech Representations that can be used for any Catalan speech-related task.
This model does not have a tokenizer as it was pretrained on audio alone.
In order to use this model for Automatic Speech Recognition, a tokenizer should be created and the model should be fine-tuned on labeled text data.
Check out
this blog for more in-detail explanation of how to fine-tune the model for Speech Recognition.
For an explanation of how to fine-tune the model for Audio Classification, check out
this tutorial.
Pre-training Details
This model was pre-trained using code from the
official repository, and the detailed training configuration can be found in the same repository and the
original paper.
For pre-training, a 1,778 hours dataset was created using subsets from training splits from the following datasets:
- 3CatParla (500 hours) (This dataset is private and is planned to be published as public soon).
- commonvoice 17 (250 hours)
- corts_valencianes (250 hours) (Only the anonymized version of the dataset is public. We trained the model with the non-anonymized version.)
- parlament_parla_v3 (250 hours)
- IB3 (28 hours)
- Catalan YouTube Speech (500 hours)
Indirect evaluation results
To assess the pre-trained Catalan Speech Representations' quality, we evaluated them using two indirect tasks: Catalan Automatic Speech Recognition (ASR) and Catalan Accent Classification.
Catalan Automatic Speech Recognition
We created train and validation ASR-labelled datasets using a 100 hours subsample from the pre-training dataset split.
For testing, we created a test split concatenating all the test splits from:
- 3CatParla (4.5 hours).
- commonvoice 17 (28 hours)
- corts_valencianes (6 hours) (Only the anonymized version of the dataset is public. We trained the model with the non-anonymized version.)
- parlament_parla_v3 (27 hours)
We fine-tuned on this ASR-labelled 100 hours training split the following models:
- Catalan pre-trained HuBERT: BSC-LT/hubert-base-ca-2k (our model)
- English pre-trained HuBERT: facebook/hubert-base-ls960
- Multi-lingual pre-trained HuBERT: utter-project/mHuBERT-147
- Multi-lingual pre-trained wav2vec2: facebook/wav2vec2-large-xlsr-53
All of these models were pre-trained using exactly the same configurations.
We trained them for 20 epochs, except wav2vec2-large-xlsr-53, that was trained for 10 epochs (to make it comparable to the others, because it takes double of time to train).
For the fine-tuning process, we froze models' parameters using the freeze_feature_encoder() method.
hubert-base-ca-2k, hubert-base-ls960 and mHuBERT-147 have 94M parameters, 95% of them were fine-tuned. wav2vec2-large-xlsr-53 has 311M parameters, 98% of them were fine-tuned.
The results were the following:
| Model | Train WER | Validation WER | Test WER ↑ |
|---|
| hubert-base-ca-2k | 5.1% | 9.6% | 12.1% |
| mHuBERT-147 | 9.4% | 14.7% | 18.1% |
| wav2vec2-large-xlsr-53 | 10.4% | 12.6% | 21.3% |
| hubert-base-ls960 | 15.8% | 21.8% | 26.5% |
Catalan Accent Classification
We created train, validation and test Catalan Accent Classification-labelled datasets using a 800 minutes (13 hours) subsample from the
projecte-aina/annotated_catalan_common_voice_v17 dataset.
For each partition and accent, there is an important imbalance in the number of speakers and in the amount of hours available.
We created new (smaller) splits assuring that:
- Every accent has the same amount of speakers
- Every speaker has at most 10 sentences (to avoid super-present speakers).
As a result of that, we obtained balanced train (730 minutes), validation (30 minutes) and test (37 minutes) splits.
We used the field “assigned_accent” as target label.
This label can take the following values: "central", "northern", "northwestern", "valencian" or "balearic".
We fine-tuned on this Catalan Accent Classification-labelled 800 minutes training split the following models:
- Catalan pre-trained HuBERT: BSC-LT/hubert-base-ca-2k (our model)
- English pre-trained HuBERT: facebook/hubert-base-ls960
- Multi-lingual pre-trained HuBERT: utter-project/mHuBERT-147
- Multi-lingual pre-trained wav2vec2: facebook/wav2vec2-large-xlsr-53
All of these models were pre-trained using exactly the same configurations.
We trained them for 10 epochs, except wav2vec2-large-xlsr-53, that was trained for 5 epochs (to make it comparable to the others, because it takes double of time to train).
For the fine-tuning process, we froze models' parameters using the freeze_base_model() method.
hubert-base-ca-2k, hubert-base-ls960 and mHuBERT-147 have 94M parameters, 0.2% of them were fine-tuned. wav2vec2-large-xlsr-53 has 311M parameters, 0.1% of them were fine-tuned.
The results were the following:
| Model | Train f1-macro | Validation f1-macro | Test f1-macro ↓ |
|---|
| hubert-base-ca-2k | 58.3% | 55.3% | 56.5% |
| mHuBERT-147 | 40.7% | 36.6% | 34.0% |
| hubert-base-ls960 | 40.6% | 34.2% | 33.6% |
| wav2vec2-large-xlsr-53 | 6.7% | 6.6% | 6.7% |
How to use the model
Speech Representations
To obtain Speech Representations (HuBERT outputs) from audio in Catalan using this model, you can follow this example:
(Using fsspec==2025.3.0, datasets==3.6.0 and transformers==4.52.2 is recomended).
1
2from datasets import load_dataset, Audio
3import torch
4from transformers import AutoFeatureExtractor, AutoModel
5
6#Load the dataset
7dataset = load_dataset("projecte-aina/ib3_ca_asr", split='train[:1%]', trust_remote_code=True)
8
9#Downsample to 16kHz
10dataset = dataset.cast_column("audio", Audio(sampling_rate=16_000))
11
12# Hugginface pre-trained model path
13MODEL_NAME = "BSC-LT/hubert-base-ca-2k"
14
15# Set device
16device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
17print(f"Using {device} device.")
18
19# Load feature extractor
20feature_extractor = AutoFeatureExtractor.from_pretrained(MODEL_NAME)
21
22# Load model
23model = AutoModel.from_pretrained(MODEL_NAME)
24model = model.to(device)
25
26def map_to_speech_representations(batch):
27
28 #Process the dataset
29 audio = batch["audio"]
30 input_features = feature_extractor(audio["array"], sampling_rate=audio["sampling_rate"], return_tensors="pt").input_values
31 input_features = input_features.to(device)
32
33 # Extract HuBERT's Speech Representations
34 with torch.no_grad():
35 outputs = model(
36 input_features,
37 output_hidden_states = True,
38 )
39 speech_representations = outputs.last_hidden_state
40 hidden_states = outputs.hidden_states
41
42 batch["speech_representations"] = speech_representations
43 batch["hidden_states"] = hidden_states
44
45 return batch
46
47dataset = dataset.map(map_to_speech_representations)
48
49print(dataset)
Discrete Speech Representations
Important remark: the k-means model available in this repo and used for extracting Discrete Speech Representations was trained using HuBERT's 6th layer.
To obtain Discrete Speech Representations (HuBERT's k-means centroids) from audio in Catalan using this model, you can follow this example:
(Using fsspec==2025.3.0, datasets==3.6.0 and transformers==4.52.2 is recomended).
1
2from datasets import load_dataset, Audio
3import torch
4from transformers import AutoFeatureExtractor, AutoModel
5import joblib
6import numpy as np
7from huggingface_hub import hf_hub_download
8
9#Load the dataset
10dataset = load_dataset("projecte-aina/ib3_ca_asr", split='train[:1%]', trust_remote_code=True)
11
12#Downsample to 16kHz
13dataset = dataset.cast_column("audio", Audio(sampling_rate=16_000))
14
15# Hugginface pre-trained model path
16MODEL_NAME = "BSC-LT/hubert-base-ca-2k"
17
18# Set device
19device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
20print(f"Using {device} device.")
21
22# Load feature extractor
23feature_extractor = AutoFeatureExtractor.from_pretrained(MODEL_NAME)
24
25# Load model
26model = AutoModel.from_pretrained(MODEL_NAME)
27model = model.to(device)
28
29# Load k-means
30km_path = hf_hub_download(repo_id="BSC-LT/hubert-base-ca-2k", filename="k_means.km")
31km_model = joblib.load(km_path)
32clusters = km_model.cluster_centers_
33
34def map_to_discrete_units(batch):
35
36 #Process the dataset
37 audio = batch["audio"]
38 input_features = feature_extractor(audio["array"], sampling_rate=audio["sampling_rate"], return_tensors="pt").input_values
39 input_features = input_features.to(device)
40
41
42 with torch.no_grad():
43 outputs = model(
44 input_features,
45 output_hidden_states = True,
46 )
47
48 # Extract HuBERT's Speech Representations
49 hidden_states = outputs.hidden_states
50
51 # Extract 6-th layer features
52 k_means_input = hidden_states[5].squeeze()
53 k_means_input = k_means_input.cpu()
54 k_means_input = np.array(k_means_input, dtype='f')
55
56 labels = km_model.predict(k_means_input)
57 batch["discrete_units"] = clusters[labels]
58
59 return batch
60
61dataset = dataset.map(map_to_discrete_units)
62
63print(dataset)
64
Automatic Speech Recognition
In order to use this model for Speech Recognition, a tokenizer should be created and the model should be fine-tuned on labeled text data.
Check out
this blog for more in-detail explanation of how to fine-tune the model for Speech Recognition.
Audio Classification
For an explanation of how to fine-tune the model for Audio Classification, check out
this tutorial.
Citation
If this model contributes to your research, please cite the work:
1@misc{costa2025hubertbaseca2k,
2 title={CaHuBERT: the first full Catalan pre-trained HuBERT.},
3 author={Costa, Federico; Messaoudi, Abir; Peiró-Lilja, Alex; Casals-Salvador, Marc; España-Bonet, Cristina},
4 organization={Barcelona Supercomputing Center},
5 url={https://huggingface.co/BSC-LT/hubert-base-ca-2k},
6 year={2025}
7}
Additional Information
Author
The pre-training process was performed during 2025, in the
Language Technologies Unit of the
Barcelona Supercomputing Center.
Contact
For further information, please send an email to
bsc-lt@bsc.es.
Copyright
Copyright(c) 2025 by Language Technologies Unit, Barcelona Supercomputing Center.
License
Funding
This work has been promoted and financed by the Generalitat de Catalunya through the
Aina project.
The training of the model was possible thanks to the computing time provided by
Barcelona Supercomputing Center through MareNostrum 5.
We acknowledge EuroHPC Joint Undertaking for awarding us access to MareNostrum5 as BSC, Spain.
Disclaimer
Click to expand
The model published in this repository is intended for a generalist purpose and is available to third parties under a permissive Apache License, Version 2.0.
Be aware that the model may have biases and/or any other undesirable distortions.
When third parties deploy or provide systems and/or services to other parties using this model (or any system based on it)
or become users of the model, they should note that it is their responsibility to mitigate the risks arising from its use and,
in any event, to comply with applicable regulations, including regulations regarding the use of Artificial Intelligence.
In no event shall the owner and creator of the model (Barcelona Supercomputing Center)
be liable for any results arising from the use made by third parties.