|
|
|
|
|
|
|
|
|
|
|
|
|
from transformers import AutoProcessor |
|
from transformers import Wav2Vec2ProcessorWithLM |
|
from pyctcdecode import build_ctcdecoder |
|
|
|
processor = AutoProcessor.from_pretrained("./") |
|
vocab_dict = processor.tokenizer.get_vocab() |
|
sorted_vocab_dict = {k.lower(): v for k, v in sorted(vocab_dict.items(), key=lambda item: item[1])} |
|
|
|
decoder = build_ctcdecoder( |
|
labels=list(sorted_vocab_dict.keys()), |
|
kenlm_model_path="5gram_correct.arpa", |
|
) |
|
|
|
processor_with_lm = Wav2Vec2ProcessorWithLM( |
|
feature_extractor=processor.feature_extractor, |
|
tokenizer=processor.tokenizer, |
|
decoder=decoder |
|
) |
|
|
|
processor_with_lm.save_pretrained("./") |
|
|