Flutter Config toJson/fromJson (#1893)

This commit is contained in:
Grey Faulkenberry, MD MPH
2025-02-25 01:43:48 -05:00
committed by GitHub
parent 808587accd
commit 70742b69ec
11 changed files with 817 additions and 17 deletions

View File

@@ -13,11 +13,27 @@ class SpeakerEmbeddingExtractorConfig {
this.debug = true,
this.provider = 'cpu'});
factory SpeakerEmbeddingExtractorConfig.fromJson(Map<String, dynamic> json) {
return SpeakerEmbeddingExtractorConfig(
model: json['model'] as String,
numThreads: json['numThreads'] as int? ?? 1,
debug: json['debug'] as bool? ?? true,
provider: json['provider'] as String? ?? 'cpu',
);
}
@override
String toString() {
return 'SpeakerEmbeddingExtractorConfig(model: $model, numThreads: $numThreads, debug: $debug, provider: $provider)';
}
Map<String, dynamic> toJson() => {
'model': model,
'numThreads': numThreads,
'debug': debug,
'provider': provider,
};
final String model;
final int numThreads;
final bool debug;