Spaces:
Build error
Build error
# Copyright 2022 Xiaomi Corp. (authors: Fangjun Kuang) | |
# | |
# See LICENSE for clarification regarding multiple authors | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
from huggingface_hub import hf_hub_download | |
from functools import lru_cache | |
from offline_asr import OfflineAsr | |
sample_rate = 16000 | |
def get_gigaspeech_pre_trained_model(): | |
nn_model_filename = hf_hub_download( | |
# It is converted from https://huggingface.co/wgb14/icefall-asr-gigaspeech-pruned-transducer-stateless2 | |
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", | |
) | |
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", | |
) | |