Automatic Speech Recognition
Transformers
Safetensors
PyTorch
English
speech-encoder-decoder
wav2vec2
bart
english
voxpopuli
Generated from Trainer
audio
master-thesis
Eval Results (legacy)
Instructions to use BUT-FIT/wav2vec2-base_bart-base_voxpopuli-en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BUT-FIT/wav2vec2-base_bart-base_voxpopuli-en with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="BUT-FIT/wav2vec2-base_bart-base_voxpopuli-en")# Load model directly from transformers import AutoTokenizer, AutoModelForSpeechSeq2Seq tokenizer = AutoTokenizer.from_pretrained("BUT-FIT/wav2vec2-base_bart-base_voxpopuli-en") model = AutoModelForSpeechSeq2Seq.from_pretrained("BUT-FIT/wav2vec2-base_bart-base_voxpopuli-en", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| from transformers import SpeechEncoderDecoderModel, AutoFeatureExtractor, AutoTokenizer | |
| # Encoder for speech feature extraction | |
| encoder_checkpoint = "facebook/wav2vec2-base-en-voxpopuli-v2" | |
| # Decoder for text generation + its tokenizer | |
| decoder_checkpoint = "facebook/bart-base" | |
| # Path where this initial combined model is saved | |
| # This path is then used as --model_name_or_path in the fine-tuning script | |
| # e.g., "./seq2seq_wav2vec2_bart-base_24k-en-voxpopuli" | |
| INITIAL_MODEL_SAVE_PATH = "path_to_save_initial_model" | |
| model = SpeechEncoderDecoderModel.from_encoder_decoder_pretrained( | |
| encoder_checkpoint, | |
| decoder_checkpoint, | |
| encoder_add_adapter=True, # Enables adapter mechanism | |
| encoder_num_adapter_layers=3, # Specifies 3 adapter layers | |
| ) | |
| # Configure encoder properties (example from thesis experiments) | |
| model.config.encoder.feat_proj_dropout = 0.0 | |
| # model.config.encoder.mask_time_prob = 0.0 # No SpecAugment at initialization | |
| # Configure decoder start token, pad token, eos token from the decoder's config | |
| model.config.decoder_start_token_id = model.decoder.config.bos_token_id | |
| model.config.pad_token_id = ( | |
| model.decoder.config.pad_token_id | |
| ) # Or tokenizer.pad_token_id | |
| model.config.eos_token_id = ( | |
| model.decoder.config.eos_token_id | |
| ) # Or tokenizer.eos_token_id | |
| # Configure generation parameters | |
| model.config.max_length = 128 | |
| model.config.encoder.layerdrop = 0.0 | |
| model.config.use_cache = False # Important for training | |
| # Save the initialized model, feature extractor, and tokenizer | |
| model.save_pretrained(INITIAL_MODEL_SAVE_PATH) | |
| feature_extractor = AutoFeatureExtractor.from_pretrained(encoder_checkpoint) | |
| feature_extractor.save_pretrained(INITIAL_MODEL_SAVE_PATH) | |
| tokenizer = AutoTokenizer.from_pretrained(decoder_checkpoint) | |
| tokenizer.save_pretrained(INITIAL_MODEL_SAVE_PATH) | |
| print( | |
| f"Initialized model, feature extractor, and tokenizer saved to {INITIAL_MODEL_SAVE_PATH}" | |
| ) | |