@@ -168,6 +168,65 @@ class OfflineMedAsrCtcModelConfig {
168168 final String model;
169169}
170170
171+ class OfflineFunAsrNanoModelConfig {
172+ const OfflineFunAsrNanoModelConfig ({
173+ this .encoderAdaptor = '' ,
174+ this .llm = '' ,
175+ this .embedding = '' ,
176+ this .tokenizer = '' ,
177+ this .systemPrompt = 'You are a helpful assistant.' ,
178+ this .userPrompt = '语音转写:' ,
179+ this .maxNewTokens = 512 ,
180+ this .temperature = 1e-6 ,
181+ this .topP = 0.8 ,
182+ this .seed = 42 ,
183+ });
184+
185+ factory OfflineFunAsrNanoModelConfig .fromJson (Map <String , dynamic > json) {
186+ return OfflineFunAsrNanoModelConfig (
187+ encoderAdaptor: json['encoderAdaptor' ] as String ? ?? '' ,
188+ llm: json['llm' ] as String ? ?? '' ,
189+ embedding: json['embedding' ] as String ? ?? '' ,
190+ tokenizer: json['tokenizer' ] as String ? ?? '' ,
191+ systemPrompt: json['systemPrompt' ] as String ? ?? '' ,
192+ userPrompt: json['userPrompt' ] as String ? ?? '' ,
193+ maxNewTokens: json['maxNewTokens' ] as int ? ?? 512 ,
194+ temperature: (json['temperature' ] as num ? )? .toDouble () ?? 1e-6 ,
195+ topP: (json['topP' ] as num ? )? .toDouble () ?? 0.8 ,
196+ seed: json['seed' ] as int ? ?? 42 ,
197+ );
198+ }
199+
200+ @override
201+ String toString () {
202+ return 'OfflineFunAsrNanoModelConfig(encoderAdaptor: $encoderAdaptor , llm: $llm , embedding: $embedding , tokenizer: $tokenizer , systemPrompt: $systemPrompt , userPrompt: $userPrompt , maxNewTokens: $maxNewTokens , temperature: $temperature , topP: $topP , seed: $seed )' ;
203+ }
204+
205+ Map <String , dynamic > toJson () => {
206+ 'encoderAdaptor' : encoderAdaptor,
207+ 'llm' : llm,
208+ 'embedding' : embedding,
209+ 'tokenizer' : tokenizer,
210+ 'systemPrompt' : systemPrompt,
211+ 'userPrompt' : userPrompt,
212+ 'maxNewTokens' : maxNewTokens,
213+ 'temperature' : temperature,
214+ 'topP' : topP,
215+ 'seed' : seed,
216+ };
217+
218+ final String encoderAdaptor;
219+ final String llm;
220+ final String embedding;
221+ final String tokenizer;
222+ final String systemPrompt;
223+ final String userPrompt;
224+ final int maxNewTokens;
225+ final double temperature;
226+ final double topP;
227+ final int seed;
228+ }
229+
171230class OfflineWhisperModelConfig {
172231 const OfflineWhisperModelConfig ({
173232 this .encoder = '' ,
@@ -388,6 +447,7 @@ class OfflineModelConfig {
388447 this .wenetCtc = const OfflineWenetCtcModelConfig (),
389448 this .omnilingual = const OfflineOmnilingualAsrCtcModelConfig (),
390449 this .medasr = const OfflineMedAsrCtcModelConfig (),
450+ this .funasrNano = const OfflineFunAsrNanoModelConfig (),
391451 required this .tokens,
392452 this .numThreads = 1 ,
393453 this .debug = true ,
@@ -470,6 +530,11 @@ class OfflineModelConfig {
470530 json['medasr' ] as Map <String , dynamic >,
471531 )
472532 : const OfflineMedAsrCtcModelConfig (),
533+ funasrNano: json['funasrNano' ] != null
534+ ? OfflineFunAsrNanoModelConfig .fromJson (
535+ json['funasrNano' ] as Map <String , dynamic >,
536+ )
537+ : const OfflineFunAsrNanoModelConfig (),
473538 tokens: json['tokens' ] as String ,
474539 numThreads: json['numThreads' ] as int ? ?? 1 ,
475540 debug: json['debug' ] as bool ? ?? true ,
@@ -483,7 +548,7 @@ class OfflineModelConfig {
483548
484549 @override
485550 String toString () {
486- return 'OfflineModelConfig(transducer: $transducer , paraformer: $paraformer , nemoCtc: $nemoCtc , whisper: $whisper , tdnn: $tdnn , senseVoice: $senseVoice , moonshine: $moonshine , fireRedAsr: $fireRedAsr , dolphin: $dolphin , zipformerCtc: $zipformerCtc , canary: $canary , wenetCtc: $wenetCtc , omnilingual: $omnilingual , medasr: $medasr , tokens: $tokens , numThreads: $numThreads , debug: $debug , provider: $provider , modelType: $modelType , modelingUnit: $modelingUnit , bpeVocab: $bpeVocab , telespeechCtc: $telespeechCtc )' ;
551+ return 'OfflineModelConfig(transducer: $transducer , paraformer: $paraformer , nemoCtc: $nemoCtc , whisper: $whisper , tdnn: $tdnn , senseVoice: $senseVoice , moonshine: $moonshine , fireRedAsr: $fireRedAsr , dolphin: $dolphin , zipformerCtc: $zipformerCtc , canary: $canary , wenetCtc: $wenetCtc , omnilingual: $omnilingual , medasr: $medasr , funasrNano: $ funasrNano , tokens: $tokens , numThreads: $numThreads , debug: $debug , provider: $provider , modelType: $modelType , modelingUnit: $modelingUnit , bpeVocab: $bpeVocab , telespeechCtc: $telespeechCtc )' ;
487552 }
488553
489554 Map <String , dynamic > toJson () => {
@@ -501,6 +566,7 @@ class OfflineModelConfig {
501566 'wenetCtc' : wenetCtc.toJson (),
502567 'omnilingual' : omnilingual.toJson (),
503568 'medasr' : medasr.toJson (),
569+ 'funasrNano' : funasrNano.toJson (),
504570 'tokens' : tokens,
505571 'numThreads' : numThreads,
506572 'debug' : debug,
@@ -525,6 +591,7 @@ class OfflineModelConfig {
525591 final OfflineWenetCtcModelConfig wenetCtc;
526592 final OfflineOmnilingualAsrCtcModelConfig omnilingual;
527593 final OfflineMedAsrCtcModelConfig medasr;
594+ final OfflineFunAsrNanoModelConfig funasrNano;
528595
529596 final String tokens;
530597 final int numThreads;
@@ -773,6 +840,25 @@ class OfflineRecognizer {
773840 .toNativeUtf8 ();
774841 c.ref.model.medasr.model = config.model.medasr.model.toNativeUtf8 ();
775842
843+ c.ref.model.funasrNano.encoderAdaptor = config
844+ .model
845+ .funasrNano
846+ .encoderAdaptor
847+ .toNativeUtf8 ();
848+ c.ref.model.funasrNano.llm = config.model.funasrNano.llm.toNativeUtf8 ();
849+ c.ref.model.funasrNano.embedding = config.model.funasrNano.embedding
850+ .toNativeUtf8 ();
851+ c.ref.model.funasrNano.tokenizer = config.model.funasrNano.tokenizer
852+ .toNativeUtf8 ();
853+ c.ref.model.funasrNano.systemPrompt = config.model.funasrNano.systemPrompt
854+ .toNativeUtf8 ();
855+ c.ref.model.funasrNano.userPrompt = config.model.funasrNano.userPrompt
856+ .toNativeUtf8 ();
857+ c.ref.model.funasrNano.maxNewTokens = config.model.funasrNano.maxNewTokens;
858+ c.ref.model.funasrNano.temperature = config.model.funasrNano.temperature;
859+ c.ref.model.funasrNano.topP = config.model.funasrNano.topP;
860+ c.ref.model.funasrNano.seed = config.model.funasrNano.seed;
861+
776862 c.ref.model.tokens = config.model.tokens.toNativeUtf8 ();
777863
778864 c.ref.model.numThreads = config.model.numThreads;
@@ -817,6 +903,12 @@ class OfflineRecognizer {
817903 calloc.free (c.ref.model.modelType);
818904 calloc.free (c.ref.model.provider);
819905 calloc.free (c.ref.model.tokens);
906+ calloc.free (c.ref.model.funasrNano.userPrompt);
907+ calloc.free (c.ref.model.funasrNano.systemPrompt);
908+ calloc.free (c.ref.model.funasrNano.tokenizer);
909+ calloc.free (c.ref.model.funasrNano.embedding);
910+ calloc.free (c.ref.model.funasrNano.llm);
911+ calloc.free (c.ref.model.funasrNano.encoderAdaptor);
820912 calloc.free (c.ref.model.medasr.model);
821913 calloc.free (c.ref.model.omnilingual.model);
822914 calloc.free (c.ref.model.wenetCtc.model);
0 commit comments