Skip to content

Instantly share code, notes, and snippets.

@zilunpeng
zilunpeng / create_decoder.py
Created March 23, 2021 21:04
Create a Viterbi decoder. Code below is part of the wav2vec 2.0 inference notebook (https://git.io/JYeKX).
decoder = W2lViterbiDecoder(target_dict)
@zilunpeng
zilunpeng / create_wav2vec2.py
Created March 23, 2021 21:03
Create and load weights into wav2vec 2.0. Code below is part of the wav2vec 2.0 inference notebook (https://git.io/JYeKX).
w2v = torch.load(model_path)
model = Wav2VecCtc.build_model(w2v["args"], target_dict)
model.load_state_dict(w2v["model"], strict=True)
@zilunpeng
zilunpeng / create_target_dict.py
Created March 23, 2021 21:01
Create mapping between tokens and indices. Code below is part of the wav2vec 2.0 inference notebook (https://git.io/JYeKX).
target_dict = fairseq_mod.data.Dictionary.load('ltr_dict.txt')
@zilunpeng
zilunpeng / model_data_path.py
Last active March 23, 2021 21:00
Specify paths to model and dataset. Code below is part of the wav2vec 2.0 inference notebook (https://git.io/JYeKX).
model_path = "/home/models/wav2vec_big_960h.pt"
data_path = "/home/datasets/"