Skip to content

Commit de0f991

Browse files
committed
change G2PWModel download
1 parent 744ea44 commit de0f991

File tree

3 files changed

+26
-47
lines changed

3 files changed

+26
-47
lines changed

MANIFEST.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
include paddlespeech/t2s/exps/*.txt
2-
include paddlespeech/t2s/frontend/*.yaml
3-
include paddlespeech/t2s/frontend/g2pw/*.json
2+
include paddlespeech/t2s/frontend/*.yaml

paddlespeech/resource/pretrained_models.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -655,24 +655,6 @@
655655
'phone_id_map.txt',
656656
},
657657
},
658-
"fastspeech2_mix-mix": {
659-
'1.0': {
660-
'url':
661-
'https://paddlespeech.bj.bcebos.com/t2s/chinse_english_mixed/models/fastspeech2_csmscljspeech_add-zhen.zip',
662-
'md5':
663-
'77d9d4b5a79ed6203339ead7ef6c74f9',
664-
'config':
665-
'default.yaml',
666-
'ckpt':
667-
'snapshot_iter_94000.pdz',
668-
'speech_stats':
669-
'speech_stats.npy',
670-
'phones_dict':
671-
'phone_id_map.txt',
672-
'speaker_dict':
673-
'speaker_id_map.txt',
674-
},
675-
},
676658
# tacotron2
677659
"tacotron2_csmsc-zh": {
678660
'1.0': {
@@ -1095,8 +1077,7 @@
10951077
'https://paddlespeech.bj.bcebos.com/Parakeet/released_models/speedyspeech/speedyspeech_csmsc_onnx_0.2.0.zip',
10961078
'md5':
10971079
'3e9c45af9ef70675fc1968ed5074fc88',
1098-
'ckpt':
1099-
'speedyspeech_csmsc.onnx',
1080+
'ckpt': ['speedyspeech_csmsc.onnx'],
11001081
'phones_dict':
11011082
'phone_id_map.txt',
11021083
'tones_dict':
@@ -1112,8 +1093,7 @@
11121093
'https://paddlespeech.bj.bcebos.com/Parakeet/released_models/fastspeech2/fastspeech2_csmsc_onnx_0.2.0.zip',
11131094
'md5':
11141095
'fd3ad38d83273ad51f0ea4f4abf3ab4e',
1115-
'ckpt':
1116-
'fastspeech2_csmsc.onnx',
1096+
'ckpt': ['fastspeech2_csmsc.onnx'],
11171097
'phones_dict':
11181098
'phone_id_map.txt',
11191099
'sample_rate':
@@ -1126,8 +1106,7 @@
11261106
'https://paddlespeech.bj.bcebos.com/Parakeet/released_models/fastspeech2/fastspeech2_ljspeech_onnx_1.1.0.zip',
11271107
'md5':
11281108
'00754307636a48c972a5f3e65cda3d18',
1129-
'ckpt':
1130-
'fastspeech2_ljspeech.onnx',
1109+
'ckpt': ['fastspeech2_ljspeech.onnx'],
11311110
'phones_dict':
11321111
'phone_id_map.txt',
11331112
'sample_rate':
@@ -1140,8 +1119,7 @@
11401119
'https://paddlespeech.bj.bcebos.com/Parakeet/released_models/fastspeech2/fastspeech2_aishell3_onnx_1.1.0.zip',
11411120
'md5':
11421121
'a1d6ee21de897ce394f5469e2bb4df0d',
1143-
'ckpt':
1144-
'fastspeech2_aishell3.onnx',
1122+
'ckpt': ['fastspeech2_aishell3.onnx'],
11451123
'phones_dict':
11461124
'phone_id_map.txt',
11471125
'speaker_dict':
@@ -1153,11 +1131,10 @@
11531131
"fastspeech2_vctk_onnx-en": {
11541132
'1.0': {
11551133
'url':
1156-
'https://paddlespeech.bj.bcebos.com/Parakeet/released_models/fastspeech2/fastspeech2_vctk_onnx_1.1.0.zip',
1134+
'hhttps://paddlespeech.bj.bcebos.com/Parakeet/released_models/fastspeech2/fastspeech2_vctk_onnx_1.1.0.zip',
11571135
'md5':
11581136
'd9c3a9b02204a2070504dd99f5f959bf',
1159-
'ckpt':
1160-
'fastspeech2_vctk.onnx',
1137+
'ckpt': ['fastspeech2_vctk.onnx'],
11611138
'phones_dict':
11621139
'phone_id_map.txt',
11631140
'speaker_dict':
@@ -1335,3 +1312,17 @@
13351312
},
13361313
},
13371314
}
1315+
1316+
# ---------------------------------
1317+
# ------------- G2PW ---------------
1318+
# ---------------------------------
1319+
g2pw_onnx_models = {
1320+
'G2PWModel': {
1321+
'1.0': {
1322+
'url':
1323+
'https://paddlespeech.bj.bcebos.com/Parakeet/released_models/g2p/G2PWModel.tar',
1324+
'md5':
1325+
'86a3dd8db0291c575c46e134111dce23',
1326+
},
1327+
},
1328+
}

paddlespeech/t2s/frontend/g2pw/onnx_api.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
from opencc import OpenCC
1111

1212
from paddlenlp.transformers import BertTokenizer
13-
13+
from paddlespeech.utils.env import MODEL_HOME
1414
from paddlespeech.t2s.frontend.g2pw.dataset import prepare_data,\
1515
prepare_onnx_input,\
1616
get_phoneme_labels,\
1717
get_char_phoneme_labels
1818
from paddlespeech.t2s.frontend.g2pw.utils import load_config
19-
20-
MODEL_URL = 'https://paddlespeech.bj.bcebos.com/Parakeet/released_models/g2p/G2PWModel.tar'
19+
from paddlespeech.cli.utils import download_and_decompress
20+
from paddlespeech.resource.pretrained_models import g2pw_onnx_models
2121

2222

2323
def predict(session, onnx_input, labels):
@@ -40,21 +40,10 @@ def predict(session, onnx_input, labels):
4040
return all_preds, all_confidences
4141

4242

43-
def download_model(model_dir):
44-
os.makedirs(model_dir, exist_ok=True)
45-
wget_shell = "cd %s && wget %s"%(model_dir,MODEL_URL)
46-
os.system(wget_shell)
47-
shell = "cd %s ;tar -xvf %s;cd %s/G2PWModel;rm -rf .*" % (model_dir,MODEL_URL.split("/")[-1], model_dir)
48-
os.system(shell)
49-
rm_shell = "cd %s && rm -rf %s"%(model_dir,MODEL_URL.split("/")[-1])
50-
os.system(rm_shell)
51-
52-
5343
class G2PWOnnxConverter:
54-
def __init__(self, style='bopomofo', model_source=None, enable_non_tradional_chinese=False):
55-
model_dir = os.path.join(os.path.expandvars('$HOME'), 'paddlespeech/models')
44+
def __init__(self, model_dir = MODEL_HOME, style='bopomofo', model_source=None, enable_non_tradional_chinese=False):
5645
if not os.path.exists(os.path.join(model_dir, 'G2PWModel/g2pW.onnx')):
57-
download_model(model_dir)
46+
uncompress_path = download_and_decompress(g2pw_onnx_models['G2PWModel']['1.0'],model_dir)
5847

5948
sess_options = onnxruntime.SessionOptions()
6049
sess_options.intra_op_num_threads = 2

0 commit comments

Comments
 (0)