|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from transformers import SpeechEncoderDecoderModel, AutoFeatureExtractor, AutoTokenizer, Wav2Vec2Processor |
|
|
|
|
|
|
|
encoder_id = "facebook/wav2vec2-base" |
|
decoder_id = "facebook/bart-base" |
|
|
|
|
|
|
|
model = SpeechEncoderDecoderModel.from_encoder_decoder_pretrained( |
|
encoder_id, |
|
decoder_id, |
|
encoder_add_adapter=True, |
|
encoder_feat_proj_dropout=0.0, |
|
encoder_layerdrop=0.0, |
|
max_length=200, |
|
num_beams=5, |
|
) |
|
model.config.decoder_start_token_id = model.decoder.config.bos_token_id |
|
model.config.pad_token_id = model.decoder.config.pad_token_id |
|
model.config.eos_token_id = model.decoder.config.eos_token_id |
|
model.save_pretrained("./") |
|
|
|
|
|
feature_extractor = AutoFeatureExtractor.from_pretrained(encoder_id) |
|
tokenizer = AutoTokenizer.from_pretrained(decoder_id) |
|
processor = Wav2Vec2Processor(feature_extractor, tokenizer) |
|
processor.save_pretrained("./") |
|
|