Committed by
GitHub
Add Flutter example for Kokoro TTS 1.0 (#1810)
正在显示
1 个修改的文件
包含
19 行增加
和
1 行删除
| @@ -92,6 +92,15 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async { | @@ -92,6 +92,15 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async { | ||
| 92 | // voices = 'voices.bin'; | 92 | // voices = 'voices.bin'; |
| 93 | // dataDir = 'kokoro-en-v0_19/espeak-ng-data'; | 93 | // dataDir = 'kokoro-en-v0_19/espeak-ng-data'; |
| 94 | 94 | ||
| 95 | + // Example 9 | ||
| 96 | + // https://k2-fsa.github.io/sherpa/onnx/tts/pretrained_models/kokoro.html | ||
| 97 | + // modelDir = 'kokoro-multi-lang-v1_0'; | ||
| 98 | + // modelName = 'model.onnx'; | ||
| 99 | + // voices = 'voices.bin'; | ||
| 100 | + // dataDir = 'kokoro-multi-lang-v1_0/espeak-ng-data'; | ||
| 101 | + // dictDir = 'kokoro-multi-lang-v1_0/dict'; | ||
| 102 | + // lexicon = 'kokoro-multi-lang-v1_0/lexicon-us-en.txt,kokoro-multi-lang-v1_0/lexicon-zh.txt'; | ||
| 103 | + | ||
| 95 | // ============================================================ | 104 | // ============================================================ |
| 96 | // Please don't change the remaining part of this function | 105 | // Please don't change the remaining part of this function |
| 97 | // ============================================================ | 106 | // ============================================================ |
| @@ -121,7 +130,14 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async { | @@ -121,7 +130,14 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async { | ||
| 121 | ruleFars = tmp.join(','); | 130 | ruleFars = tmp.join(','); |
| 122 | } | 131 | } |
| 123 | 132 | ||
| 124 | - if (lexicon != '') { | 133 | + if (lexicon.contains(',')) { |
| 134 | + final all = lexicon.split(','); | ||
| 135 | + var tmp = <String>[]; | ||
| 136 | + for (final f in all) { | ||
| 137 | + tmp.add(p.join(directory.path, f)); | ||
| 138 | + } | ||
| 139 | + lexicon = tmp.join(','); | ||
| 140 | + } else if (lexicon != '') { | ||
| 125 | lexicon = p.join(directory.path, modelDir, lexicon); | 141 | lexicon = p.join(directory.path, modelDir, lexicon); |
| 126 | } | 142 | } |
| 127 | 143 | ||
| @@ -148,6 +164,8 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async { | @@ -148,6 +164,8 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async { | ||
| 148 | voices: voices, | 164 | voices: voices, |
| 149 | tokens: tokens, | 165 | tokens: tokens, |
| 150 | dataDir: dataDir, | 166 | dataDir: dataDir, |
| 167 | + dictDir: dictDir, | ||
| 168 | + lexicon: lexicon, | ||
| 151 | ); | 169 | ); |
| 152 | } else { | 170 | } else { |
| 153 | vits = sherpa_onnx.OfflineTtsVitsModelConfig( | 171 | vits = sherpa_onnx.OfflineTtsVitsModelConfig( |
-
请 注册 或 登录 后发表评论