Skip to content

Commit c49bbce

Browse files
authored
Add Flutter example for Kokoro TTS 1.0 (k2-fsa#1810)
1 parent 0610679 commit c49bbce

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

flutter-examples/tts/lib/model.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async {
9292
// voices = 'voices.bin';
9393
// dataDir = 'kokoro-en-v0_19/espeak-ng-data';
9494

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+
95104
// ============================================================
96105
// Please don't change the remaining part of this function
97106
// ============================================================
@@ -121,7 +130,14 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async {
121130
ruleFars = tmp.join(',');
122131
}
123132

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 != '') {
125141
lexicon = p.join(directory.path, modelDir, lexicon);
126142
}
127143

@@ -148,6 +164,8 @@ Future<sherpa_onnx.OfflineTts> createOfflineTts() async {
148164
voices: voices,
149165
tokens: tokens,
150166
dataDir: dataDir,
167+
dictDir: dictDir,
168+
lexicon: lexicon,
151169
);
152170
} else {
153171
vits = sherpa_onnx.OfflineTtsVitsModelConfig(

0 commit comments

Comments
 (0)