@@ -60,22 +60,45 @@ class OfflineTtsMatchaModelConfig {
6060 final String dictDir;
6161}
6262
63+ class OfflineTtsKokoroModelConfig {
64+ const OfflineTtsKokoroModelConfig ({
65+ this .model = '' ,
66+ this .voices = '' ,
67+ this .tokens = '' ,
68+ this .dataDir = '' ,
69+ this .lengthScale = 1.0 ,
70+ });
71+
72+ @override
73+ String toString () {
74+ return 'OfflineTtsKokoroModelConfig(model: $model , voices: $voices , tokens: $tokens , dataDir: $dataDir , lengthScale: $lengthScale )' ;
75+ }
76+
77+ final String model;
78+ final String voices;
79+ final String tokens;
80+ final String dataDir;
81+ final double lengthScale;
82+ }
83+
6384class OfflineTtsModelConfig {
6485 const OfflineTtsModelConfig ({
6586 this .vits = const OfflineTtsVitsModelConfig (),
6687 this .matcha = const OfflineTtsMatchaModelConfig (),
88+ this .kokoro = const OfflineTtsKokoroModelConfig (),
6789 this .numThreads = 1 ,
6890 this .debug = true ,
6991 this .provider = 'cpu' ,
7092 });
7193
7294 @override
7395 String toString () {
74- return 'OfflineTtsModelConfig(vits: $vits , matcha: $matcha , numThreads: $numThreads , debug: $debug , provider: $provider )' ;
96+ return 'OfflineTtsModelConfig(vits: $vits , matcha: $matcha , kokoro: $ kokoro , numThreads: $numThreads , debug: $debug , provider: $provider )' ;
7597 }
7698
7799 final OfflineTtsVitsModelConfig vits;
78100 final OfflineTtsMatchaModelConfig matcha;
101+ final OfflineTtsKokoroModelConfig kokoro;
79102 final int numThreads;
80103 final bool debug;
81104 final String provider;
@@ -138,6 +161,12 @@ class OfflineTts {
138161 c.ref.model.matcha.lengthScale = config.model.matcha.lengthScale;
139162 c.ref.model.matcha.dictDir = config.model.matcha.dictDir.toNativeUtf8 ();
140163
164+ c.ref.model.kokoro.model = config.model.kokoro.model.toNativeUtf8 ();
165+ c.ref.model.kokoro.voices = config.model.kokoro.voices.toNativeUtf8 ();
166+ c.ref.model.kokoro.tokens = config.model.kokoro.tokens.toNativeUtf8 ();
167+ c.ref.model.kokoro.dataDir = config.model.kokoro.dataDir.toNativeUtf8 ();
168+ c.ref.model.kokoro.lengthScale = config.model.kokoro.lengthScale;
169+
141170 c.ref.model.numThreads = config.model.numThreads;
142171 c.ref.model.debug = config.model.debug ? 1 : 0 ;
143172 c.ref.model.provider = config.model.provider.toNativeUtf8 ();
@@ -151,12 +180,19 @@ class OfflineTts {
151180 calloc.free (c.ref.ruleFars);
152181 calloc.free (c.ref.ruleFsts);
153182 calloc.free (c.ref.model.provider);
183+
184+ calloc.free (c.ref.model.kokoro.dataDir);
185+ calloc.free (c.ref.model.kokoro.tokens);
186+ calloc.free (c.ref.model.kokoro.voices);
187+ calloc.free (c.ref.model.kokoro.model);
188+
154189 calloc.free (c.ref.model.matcha.dictDir);
155190 calloc.free (c.ref.model.matcha.dataDir);
156191 calloc.free (c.ref.model.matcha.tokens);
157192 calloc.free (c.ref.model.matcha.lexicon);
158193 calloc.free (c.ref.model.matcha.vocoder);
159194 calloc.free (c.ref.model.matcha.acousticModel);
195+
160196 calloc.free (c.ref.model.vits.dictDir);
161197 calloc.free (c.ref.model.vits.dataDir);
162198 calloc.free (c.ref.model.vits.tokens);
0 commit comments