|
from transformers import Wav2Vec2ForCTC, Wav2Vec2CTCTokenizer, Wav2Vec2FeatureExtractor, Wav2Vec2Processor |
|
import json |
|
|
|
|
|
local_model_path = './wav2vec2-base-mal' |
|
vocab_path = './vocab.json' |
|
|
|
|
|
model_id = "aoxo/wav2vec2-base-mal" |
|
|
|
|
|
with open(vocab_path, 'r') as f: |
|
vocab_dict = json.load(f) |
|
|
|
|
|
tokenizer = Wav2Vec2CTCTokenizer( |
|
vocab_path, |
|
unk_token="[UNK]", |
|
pad_token="[PAD]", |
|
word_delimiter_token="|" |
|
) |
|
|
|
|
|
feature_extractor = Wav2Vec2FeatureExtractor( |
|
feature_size=1, |
|
sampling_rate=16000, |
|
padding_value=0.0, |
|
do_normalize=True, |
|
return_attention_mask=False |
|
) |
|
|
|
|
|
processor = Wav2Vec2Processor( |
|
feature_extractor=feature_extractor, |
|
tokenizer=tokenizer |
|
) |
|
|
|
|
|
model = Wav2Vec2ForCTC.from_pretrained(local_model_path) |
|
|
|
|
|
model.push_to_hub(model_id) |
|
processor.push_to_hub(model_id) |
|
tokenizer.push_to_hub(model_id) |
|
|
|
print(f"Model, processor, and tokenizer successfully pushed to {model_id}") |