-
Notifications
You must be signed in to change notification settings - Fork 6
/
hubconf.py
48 lines (37 loc) · 915 Bytes
/
hubconf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
File [ hubconf.py ]
Author [ Heng-Jui Chang (MIT CSAIL) ]
Synopsis [ Hubconf. ]
"""
import os
import torch
from miniasr.utils import load_from_checkpoint
def asr_local(ckpt):
"""
ASR model from a local checkpoint.
"""
assert os.path.isfile(ckpt)
model, _, _ = load_from_checkpoint(ckpt, "cpu")
return model
def asr_url(ckpt):
"""
ASR model from an url.
"""
ckpt = torch.hub.load_state_dict_from_url(ckpt)
model, _, _ = load_from_checkpoint(ckpt, "cpu")
return model
def ctc_eng():
"""
Default Englsih CTC model.
"""
return ctc_eng_ls960_hubert_base_char()
def ctc_eng_ls960_hubert_base_char():
"""
Language: English
Data: LibriSpeech 960h
Feature: HuBERT base
Vocab: char
"""
return asr_url(
"https://www.dropbox.com/s/1k3mpngqpinihlo/ctc_ls960_hubert_base_char.ckpt?dl=0"
)