Create README.md
Browse files- pretrained/README.md +21 -0
pretrained/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This pretrained model has been fixed according to [fairseq/issues/4585](https://github.com/facebookresearch/fairseq/issues/4585) and you don't need to run `fix_xlsr.py` again.
|
| 2 |
+
|
| 3 |
+
If you download the pretrained model from [official website](https://dl.fbaipublicfiles.com/fairseq/wav2vec/xlsr_53_56k.pt), you need to fix the model using the following scripts:
|
| 4 |
+
```python
|
| 5 |
+
import torch
|
| 6 |
+
import os
|
| 7 |
+
from omegaconf import DictConfig, open_dict
|
| 8 |
+
|
| 9 |
+
assert os.path.exists("pretrained/xlsr_53_56k.pt"), "Please download the pretrained model xlsr_53_56k.pt from https://dl.fbaipublicfiles.com/fairseq/wav2vec/xlsr_53_56k.pt and put it in the 'pretrained' folder!"
|
| 10 |
+
|
| 11 |
+
cp_path = "pretrained/xlsr_53_56k.pt"
|
| 12 |
+
cp = torch.load(cp_path, map_location='cpu', weights_only=False)
|
| 13 |
+
wrong_key = ['eval_wer','eval_wer_config', 'eval_wer_tokenizer', 'eval_wer_post_process', 'autoregressive']
|
| 14 |
+
cfg = DictConfig(cp['cfg'])
|
| 15 |
+
with open_dict(cfg):
|
| 16 |
+
for k in wrong_key:
|
| 17 |
+
cfg.task.pop(k)
|
| 18 |
+
cp['cfg'] = cfg
|
| 19 |
+
torch.save(cp, "pretrained/xlsr_53_56k.pt")
|
| 20 |
+
print("Done")
|
| 21 |
+
```
|