|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from huggingface_hub import hf_hub_download |
|
from functools import lru_cache |
|
|
|
|
|
from offline_asr import OfflineAsr |
|
|
|
sample_rate = 16000 |
|
|
|
|
|
@lru_cache(maxsize=1) |
|
def get_gigaspeech_pre_trained_model(): |
|
nn_model_filename = hf_hub_download( |
|
|
|
repo_id="csukuangfj/icefall-asr-gigaspeech-pruned-transducer-stateless2", |
|
filename="cpu_jit-epoch-29-avg-11-torch-1.10.0.pt", |
|
subfolder="exp", |
|
) |
|
|
|
bpe_model_filename = hf_hub_download( |
|
repo_id="wgb14/icefall-asr-gigaspeech-pruned-transducer-stateless2", |
|
filename="bpe.model", |
|
subfolder="data/lang_bpe_500", |
|
) |
|
|
|
return OfflineAsr( |
|
nn_model_filename=nn_model_filename, |
|
bpe_model_filename=bpe_model_filename, |
|
token_filename=None, |
|
decoding_method="greedy_search", |
|
num_active_paths=4, |
|
sample_rate=sample_rate, |
|
device="cpu", |
|
) |
|
|
|
|
|
@lru_cache(maxsize=1) |
|
def get_wenetspeech_pre_trained_model(): |
|
nn_model_filename = hf_hub_download( |
|
repo_id="luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2", |
|
filename="cpu_jit_epoch_10_avg_2_torch_1.7.1.pt", |
|
subfolder="exp", |
|
) |
|
|
|
token_filename = hf_hub_download( |
|
repo_id="luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2", |
|
filename="tokens.txt", |
|
subfolder="data/lang_char", |
|
) |
|
|
|
return OfflineAsr( |
|
nn_model_filename=nn_model_filename, |
|
bpe_model_filename=None, |
|
token_filename=token_filename, |
|
decoding_method="greedy_search", |
|
num_active_paths=4, |
|
sample_rate=sample_rate, |
|
device="cpu", |
|
) |
|
|