|
11 | 11 |
|
12 | 12 | Usage:
|
13 | 13 |
|
14 |
| -Example (1/3) |
| 14 | +Example (1/4) |
15 | 15 |
|
16 | 16 | wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-amy-low.tar.bz2
|
17 | 17 | tar xf vits-piper-en_US-amy-low.tar.bz2
|
|
23 | 23 | --output-filename=./generated.wav \
|
24 | 24 | "Today as always, men fall into two groups: slaves and free men. Whoever does not have two-thirds of his day for himself, is a slave, whatever he may be: a statesman, a businessman, an official, or a scholar."
|
25 | 25 |
|
26 |
| -Example (2/3) |
| 26 | +Example (2/4) |
27 | 27 |
|
28 | 28 | wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-zh-aishell3.tar.bz2
|
29 | 29 | tar xvf vits-zh-aishell3.tar.bz2
|
|
37 | 37 | --output-filename=./liubei-21.wav \
|
38 | 38 | "勿以恶小而为之,勿以善小而不为。惟贤惟德,能服于人。122334"
|
39 | 39 |
|
40 |
| -Example (3/3) |
| 40 | +Example (3/4) |
41 | 41 |
|
42 | 42 | wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-vits-zh-ll.tar.bz2
|
43 | 43 | tar xvf sherpa-onnx-vits-zh-ll.tar.bz2
|
|
53 | 53 | --output-filename=./test-2.wav \
|
54 | 54 | "当夜幕降临,星光点点,伴随着微风拂面,我在静谧中感受着时光的流转,思念如涟漪荡漾,梦境如画卷展开,我与自然融为一体,沉静在这片宁静的美丽之中,感受着生命的奇迹与温柔。2024年5月11号,拨打110或者18920240511。123456块钱。"
|
55 | 55 |
|
| 56 | +Example (4/4) |
| 57 | +
|
| 58 | +curl -O -SL https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/matcha-icefall-zh-baker.tar.bz2 |
| 59 | +tar xvf matcha-icefall-zh-baker.tar.bz2 |
| 60 | +rm matcha-icefall-zh-baker.tar.bz2 |
| 61 | +
|
| 62 | +curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/vocoder-models/hifigan_v2.onnx |
| 63 | +
|
| 64 | +python3 ./python-api-examples/offline-tts-play.py \ |
| 65 | + --matcha-acoustic-model=./matcha-icefall-zh-baker/model-steps-3.onnx \ |
| 66 | + --matcha-vocoder=./hifigan_v2.onnx \ |
| 67 | + --matcha-lexicon=./matcha-icefall-zh-baker/lexicon.txt \ |
| 68 | + --matcha-tokens=./matcha-icefall-zh-baker/tokens.txt \ |
| 69 | + --tts-rule-fsts=./matcha-icefall-zh-baker/phone.fst,./matcha-icefall-zh-baker/date.fst,./matcha-icefall-zh-baker/number.fst \ |
| 70 | + --matcha-dict-dir=./matcha-icefall-zh-baker/dict \ |
| 71 | + --output-filename=./test-matcha.wav \ |
| 72 | + "某某银行的副行长和一些行政领导表示,他们去过长江和长白山; 经济不断增长。2024年12月31号,拨打110或者18920240511。123456块钱。" |
| 73 | +
|
56 | 74 |
|
57 | 75 | You can find more models at
|
58 | 76 | https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
|
|
84 | 102 | sys.exit(-1)
|
85 | 103 |
|
86 | 104 |
|
87 |
| -def get_args(): |
88 |
| - parser = argparse.ArgumentParser( |
89 |
| - formatter_class=argparse.ArgumentDefaultsHelpFormatter |
90 |
| - ) |
91 |
| - |
| 105 | +def add_vits_args(parser): |
92 | 106 | parser.add_argument(
|
93 | 107 | "--vits-model",
|
94 | 108 | type=str,
|
| 109 | + default="", |
95 | 110 | help="Path to vits model.onnx",
|
96 | 111 | )
|
97 | 112 |
|
@@ -124,6 +139,60 @@ def get_args():
|
124 | 139 | help="Path to the dict directory for models using jieba",
|
125 | 140 | )
|
126 | 141 |
|
| 142 | + |
| 143 | +def add_matcha_args(parser): |
| 144 | + parser.add_argument( |
| 145 | + "--matcha-acoustic-model", |
| 146 | + type=str, |
| 147 | + default="", |
| 148 | + help="Path to model.onnx for matcha", |
| 149 | + ) |
| 150 | + |
| 151 | + parser.add_argument( |
| 152 | + "--matcha-vocoder", |
| 153 | + type=str, |
| 154 | + default="", |
| 155 | + help="Path to vocoder for matcha", |
| 156 | + ) |
| 157 | + |
| 158 | + parser.add_argument( |
| 159 | + "--matcha-lexicon", |
| 160 | + type=str, |
| 161 | + default="", |
| 162 | + help="Path to lexicon.txt for matcha", |
| 163 | + ) |
| 164 | + |
| 165 | + parser.add_argument( |
| 166 | + "--matcha-tokens", |
| 167 | + type=str, |
| 168 | + default="", |
| 169 | + help="Path to tokens.txt for matcha", |
| 170 | + ) |
| 171 | + |
| 172 | + parser.add_argument( |
| 173 | + "--matcha-data-dir", |
| 174 | + type=str, |
| 175 | + default="", |
| 176 | + help="""Path to the dict directory of espeak-ng. If it is specified, |
| 177 | + --matcha-lexicon and --matcha-tokens are ignored""", |
| 178 | + ) |
| 179 | + |
| 180 | + parser.add_argument( |
| 181 | + "--matcha-dict-dir", |
| 182 | + type=str, |
| 183 | + default="", |
| 184 | + help="Path to the dict directory for models using jieba", |
| 185 | + ) |
| 186 | + |
| 187 | + |
| 188 | +def get_args(): |
| 189 | + parser = argparse.ArgumentParser( |
| 190 | + formatter_class=argparse.ArgumentDefaultsHelpFormatter |
| 191 | + ) |
| 192 | + |
| 193 | + add_vits_args(parser) |
| 194 | + add_matcha_args(parser) |
| 195 | + |
127 | 196 | parser.add_argument(
|
128 | 197 | "--tts-rule-fsts",
|
129 | 198 | type=str,
|
@@ -313,6 +382,14 @@ def main():
|
313 | 382 | dict_dir=args.vits_dict_dir,
|
314 | 383 | tokens=args.vits_tokens,
|
315 | 384 | ),
|
| 385 | + matcha=sherpa_onnx.OfflineTtsMatchaModelConfig( |
| 386 | + acoustic_model=args.matcha_acoustic_model, |
| 387 | + vocoder=args.matcha_vocoder, |
| 388 | + lexicon=args.matcha_lexicon, |
| 389 | + tokens=args.matcha_tokens, |
| 390 | + data_dir=args.matcha_data_dir, |
| 391 | + dict_dir=args.matcha_dict_dir, |
| 392 | + ), |
316 | 393 | provider=args.provider,
|
317 | 394 | debug=args.debug,
|
318 | 395 | num_threads=args.num_threads,
|
|
0 commit comments