Flutter Config toJson/fromJson (#1893)
This commit is contained in:
committed by
GitHub
parent
808587accd
commit
70742b69ec
@@ -8,11 +8,24 @@ import './sherpa_onnx_bindings.dart';
|
|||||||
class OfflineZipformerAudioTaggingModelConfig {
|
class OfflineZipformerAudioTaggingModelConfig {
|
||||||
const OfflineZipformerAudioTaggingModelConfig({this.model = ''});
|
const OfflineZipformerAudioTaggingModelConfig({this.model = ''});
|
||||||
|
|
||||||
|
factory OfflineZipformerAudioTaggingModelConfig.fromJson(
|
||||||
|
Map<String, dynamic> map) {
|
||||||
|
return OfflineZipformerAudioTaggingModelConfig(
|
||||||
|
model: map['model'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineZipformerAudioTaggingModelConfig(model: $model)';
|
return 'OfflineZipformerAudioTaggingModelConfig(model: $model)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'model': model,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,11 +37,32 @@ class AudioTaggingModelConfig {
|
|||||||
this.provider = 'cpu',
|
this.provider = 'cpu',
|
||||||
this.debug = true});
|
this.debug = true});
|
||||||
|
|
||||||
|
factory AudioTaggingModelConfig.fromJson(Map<String, dynamic> map) {
|
||||||
|
return AudioTaggingModelConfig(
|
||||||
|
zipformer:
|
||||||
|
OfflineZipformerAudioTaggingModelConfig.fromJson(map['zipformer']),
|
||||||
|
ced: map['ced'] ?? '',
|
||||||
|
numThreads: map['numThreads'] ?? 1,
|
||||||
|
provider: map['provider'] ?? 'cpu',
|
||||||
|
debug: map['debug'] ?? true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AudioTaggingModelConfig(zipformer: $zipformer, ced: $ced, numThreads: $numThreads, provider: $provider, debug: $debug)';
|
return 'AudioTaggingModelConfig(zipformer: $zipformer, ced: $ced, numThreads: $numThreads, provider: $provider, debug: $debug)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'zipformer': zipformer.toJson(),
|
||||||
|
'ced': ced,
|
||||||
|
'numThreads': numThreads,
|
||||||
|
'provider': provider,
|
||||||
|
'debug': debug,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
final OfflineZipformerAudioTaggingModelConfig zipformer;
|
final OfflineZipformerAudioTaggingModelConfig zipformer;
|
||||||
final String ced;
|
final String ced;
|
||||||
final int numThreads;
|
final int numThreads;
|
||||||
@@ -39,11 +73,25 @@ class AudioTaggingModelConfig {
|
|||||||
class AudioTaggingConfig {
|
class AudioTaggingConfig {
|
||||||
AudioTaggingConfig({required this.model, this.labels = ''});
|
AudioTaggingConfig({required this.model, this.labels = ''});
|
||||||
|
|
||||||
|
factory AudioTaggingConfig.fromJson(Map<String, dynamic> map) {
|
||||||
|
return AudioTaggingConfig(
|
||||||
|
model: AudioTaggingModelConfig.fromJson(map['model']),
|
||||||
|
labels: map['labels'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AudioTaggingConfig(model: $model, labels: $labels)';
|
return 'AudioTaggingConfig(model: $model, labels: $labels)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'model': model.toJson(),
|
||||||
|
'labels': labels,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
final AudioTaggingModelConfig model;
|
final AudioTaggingModelConfig model;
|
||||||
final String labels;
|
final String labels;
|
||||||
}
|
}
|
||||||
@@ -51,11 +99,27 @@ class AudioTaggingConfig {
|
|||||||
class AudioEvent {
|
class AudioEvent {
|
||||||
AudioEvent({required this.name, required this.index, required this.prob});
|
AudioEvent({required this.name, required this.index, required this.prob});
|
||||||
|
|
||||||
|
factory AudioEvent.fromJson(Map<String, dynamic> map) {
|
||||||
|
return AudioEvent(
|
||||||
|
name: map['name'],
|
||||||
|
index: map['index'],
|
||||||
|
prob: map['prob'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AudioEvent(name: $name, index: $index, prob: $prob)';
|
return 'AudioEvent(name: $name, index: $index, prob: $prob)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'name': name,
|
||||||
|
'index': index,
|
||||||
|
'prob': prob,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final int index;
|
final int index;
|
||||||
final double prob;
|
final double prob;
|
||||||
|
|||||||
@@ -3,11 +3,23 @@
|
|||||||
class FeatureConfig {
|
class FeatureConfig {
|
||||||
const FeatureConfig({this.sampleRate = 16000, this.featureDim = 80});
|
const FeatureConfig({this.sampleRate = 16000, this.featureDim = 80});
|
||||||
|
|
||||||
|
factory FeatureConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return FeatureConfig(
|
||||||
|
sampleRate: json['sampleRate'] as int? ?? 16000,
|
||||||
|
featureDim: json['featureDim'] as int? ?? 80,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'FeatureConfig(sampleRate: $sampleRate, featureDim: $featureDim)';
|
return 'FeatureConfig(sampleRate: $sampleRate, featureDim: $featureDim)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'sampleRate': sampleRate,
|
||||||
|
'featureDim': featureDim,
|
||||||
|
};
|
||||||
|
|
||||||
final int sampleRate;
|
final int sampleRate;
|
||||||
final int featureDim;
|
final int featureDim;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,40 @@ class KeywordSpotterConfig {
|
|||||||
this.keywordsBufSize = 0,
|
this.keywordsBufSize = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory KeywordSpotterConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return KeywordSpotterConfig(
|
||||||
|
feat: json['feat'] != null
|
||||||
|
? FeatureConfig.fromJson(json['feat'] as Map<String, dynamic>)
|
||||||
|
: const FeatureConfig(),
|
||||||
|
model: OnlineModelConfig.fromJson(json['model'] as Map<String, dynamic>),
|
||||||
|
maxActivePaths: json['maxActivePaths'] as int? ?? 4,
|
||||||
|
numTrailingBlanks: json['numTrailingBlanks'] as int? ?? 1,
|
||||||
|
keywordsScore: (json['keywordsScore'] as num?)?.toDouble() ?? 1.0,
|
||||||
|
keywordsThreshold:
|
||||||
|
(json['keywordsThreshold'] as num?)?.toDouble() ?? 0.25,
|
||||||
|
keywordsFile: json['keywordsFile'] as String? ?? '',
|
||||||
|
keywordsBuf: json['keywordsBuf'] as String? ?? '',
|
||||||
|
keywordsBufSize: json['keywordsBufSize'] as int? ?? 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'KeywordSpotterConfig(feat: $feat, model: $model, maxActivePaths: $maxActivePaths, numTrailingBlanks: $numTrailingBlanks, keywordsScore: $keywordsScore, keywordsThreshold: $keywordsThreshold, keywordsFile: $keywordsFile, keywordsBuf: $keywordsBuf, keywordsBufSize: $keywordsBufSize)';
|
return 'KeywordSpotterConfig(feat: $feat, model: $model, maxActivePaths: $maxActivePaths, numTrailingBlanks: $numTrailingBlanks, keywordsScore: $keywordsScore, keywordsThreshold: $keywordsThreshold, keywordsFile: $keywordsFile, keywordsBuf: $keywordsBuf, keywordsBufSize: $keywordsBufSize)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'feat': feat.toJson(),
|
||||||
|
'model': model.toJson(),
|
||||||
|
'maxActivePaths': maxActivePaths,
|
||||||
|
'numTrailingBlanks': numTrailingBlanks,
|
||||||
|
'keywordsScore': keywordsScore,
|
||||||
|
'keywordsThreshold': keywordsThreshold,
|
||||||
|
'keywordsFile': keywordsFile,
|
||||||
|
'keywordsBuf': keywordsBuf,
|
||||||
|
'keywordsBufSize': keywordsBufSize,
|
||||||
|
};
|
||||||
|
|
||||||
final FeatureConfig feat;
|
final FeatureConfig feat;
|
||||||
final OnlineModelConfig model;
|
final OnlineModelConfig model;
|
||||||
|
|
||||||
@@ -44,11 +73,21 @@ class KeywordSpotterConfig {
|
|||||||
class KeywordResult {
|
class KeywordResult {
|
||||||
KeywordResult({required this.keyword});
|
KeywordResult({required this.keyword});
|
||||||
|
|
||||||
|
factory KeywordResult.fromJson(Map<String, dynamic> json) {
|
||||||
|
return KeywordResult(
|
||||||
|
keyword: json['keyword'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'KeywordResult(keyword: $keyword)';
|
return 'KeywordResult(keyword: $keyword)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'keyword': keyword,
|
||||||
|
};
|
||||||
|
|
||||||
final String keyword;
|
final String keyword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,27 @@ class OfflinePunctuationModelConfig {
|
|||||||
this.provider = 'cpu',
|
this.provider = 'cpu',
|
||||||
this.debug = true});
|
this.debug = true});
|
||||||
|
|
||||||
|
factory OfflinePunctuationModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflinePunctuationModelConfig(
|
||||||
|
ctTransformer: json['ctTransformer'] as String,
|
||||||
|
numThreads: json['numThreads'] as int? ?? 1,
|
||||||
|
provider: json['provider'] as String? ?? 'cpu',
|
||||||
|
debug: json['debug'] as bool? ?? true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflinePunctuationModelConfig(ctTransformer: $ctTransformer, numThreads: $numThreads, provider: $provider, debug: $debug)';
|
return 'OfflinePunctuationModelConfig(ctTransformer: $ctTransformer, numThreads: $numThreads, provider: $provider, debug: $debug)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'ctTransformer': ctTransformer,
|
||||||
|
'numThreads': numThreads,
|
||||||
|
'provider': provider,
|
||||||
|
'debug': debug,
|
||||||
|
};
|
||||||
|
|
||||||
final String ctTransformer;
|
final String ctTransformer;
|
||||||
final int numThreads;
|
final int numThreads;
|
||||||
final String provider;
|
final String provider;
|
||||||
@@ -27,11 +43,22 @@ class OfflinePunctuationConfig {
|
|||||||
required this.model,
|
required this.model,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflinePunctuationConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflinePunctuationConfig(
|
||||||
|
model: OfflinePunctuationModelConfig.fromJson(
|
||||||
|
json['model'] as Map<String, dynamic>),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflinePunctuationConfig(model: $model)';
|
return 'OfflinePunctuationConfig(model: $model)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model.toJson(),
|
||||||
|
};
|
||||||
|
|
||||||
final OfflinePunctuationModelConfig model;
|
final OfflinePunctuationModelConfig model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,25 @@ class OfflineTransducerModelConfig {
|
|||||||
this.joiner = '',
|
this.joiner = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineTransducerModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineTransducerModelConfig(
|
||||||
|
encoder: json['encoder'] as String? ?? '',
|
||||||
|
decoder: json['decoder'] as String? ?? '',
|
||||||
|
joiner: json['joiner'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineTransducerModelConfig(encoder: $encoder, decoder: $decoder, joiner: $joiner)';
|
return 'OfflineTransducerModelConfig(encoder: $encoder, decoder: $decoder, joiner: $joiner)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'encoder': encoder,
|
||||||
|
'decoder': decoder,
|
||||||
|
'joiner': joiner,
|
||||||
|
};
|
||||||
|
|
||||||
final String encoder;
|
final String encoder;
|
||||||
final String decoder;
|
final String decoder;
|
||||||
final String joiner;
|
final String joiner;
|
||||||
@@ -29,22 +43,42 @@ class OfflineTransducerModelConfig {
|
|||||||
class OfflineParaformerModelConfig {
|
class OfflineParaformerModelConfig {
|
||||||
const OfflineParaformerModelConfig({this.model = ''});
|
const OfflineParaformerModelConfig({this.model = ''});
|
||||||
|
|
||||||
|
factory OfflineParaformerModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineParaformerModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineParaformerModelConfig(model: $model)';
|
return 'OfflineParaformerModelConfig(model: $model)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
}
|
}
|
||||||
|
|
||||||
class OfflineNemoEncDecCtcModelConfig {
|
class OfflineNemoEncDecCtcModelConfig {
|
||||||
const OfflineNemoEncDecCtcModelConfig({this.model = ''});
|
const OfflineNemoEncDecCtcModelConfig({this.model = ''});
|
||||||
|
|
||||||
|
factory OfflineNemoEncDecCtcModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineNemoEncDecCtcModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineNemoEncDecCtcModelConfig(model: $model)';
|
return 'OfflineNemoEncDecCtcModelConfig(model: $model)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,11 +90,29 @@ class OfflineWhisperModelConfig {
|
|||||||
this.task = '',
|
this.task = '',
|
||||||
this.tailPaddings = -1});
|
this.tailPaddings = -1});
|
||||||
|
|
||||||
|
factory OfflineWhisperModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineWhisperModelConfig(
|
||||||
|
encoder: json['encoder'] as String? ?? '',
|
||||||
|
decoder: json['decoder'] as String? ?? '',
|
||||||
|
language: json['language'] as String? ?? '',
|
||||||
|
task: json['task'] as String? ?? '',
|
||||||
|
tailPaddings: json['tailPaddings'] as int? ?? -1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineWhisperModelConfig(encoder: $encoder, decoder: $decoder, language: $language, task: $task, tailPaddings: $tailPaddings)';
|
return 'OfflineWhisperModelConfig(encoder: $encoder, decoder: $decoder, language: $language, task: $task, tailPaddings: $tailPaddings)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'encoder': encoder,
|
||||||
|
'decoder': decoder,
|
||||||
|
'language': language,
|
||||||
|
'task': task,
|
||||||
|
'tailPaddings': tailPaddings,
|
||||||
|
};
|
||||||
|
|
||||||
final String encoder;
|
final String encoder;
|
||||||
final String decoder;
|
final String decoder;
|
||||||
final String language;
|
final String language;
|
||||||
@@ -69,15 +121,25 @@ class OfflineWhisperModelConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OfflineFireRedAsrModelConfig {
|
class OfflineFireRedAsrModelConfig {
|
||||||
const OfflineFireRedAsrModelConfig(
|
const OfflineFireRedAsrModelConfig({this.encoder = '', this.decoder = ''});
|
||||||
{this.encoder = '',
|
|
||||||
this.decoder = ''});
|
factory OfflineFireRedAsrModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineFireRedAsrModelConfig(
|
||||||
|
encoder: json['encoder'] as String? ?? '',
|
||||||
|
decoder: json['decoder'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineFireRedAsrModelConfig(encoder: $encoder, decoder: $decoder)';
|
return 'OfflineFireRedAsrModelConfig(encoder: $encoder, decoder: $decoder)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'encoder': encoder,
|
||||||
|
'decoder': decoder,
|
||||||
|
};
|
||||||
|
|
||||||
final String encoder;
|
final String encoder;
|
||||||
final String decoder;
|
final String decoder;
|
||||||
}
|
}
|
||||||
@@ -89,11 +151,27 @@ class OfflineMoonshineModelConfig {
|
|||||||
this.uncachedDecoder = '',
|
this.uncachedDecoder = '',
|
||||||
this.cachedDecoder = ''});
|
this.cachedDecoder = ''});
|
||||||
|
|
||||||
|
factory OfflineMoonshineModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineMoonshineModelConfig(
|
||||||
|
preprocessor: json['preprocessor'] as String? ?? '',
|
||||||
|
encoder: json['encoder'] as String? ?? '',
|
||||||
|
uncachedDecoder: json['uncachedDecoder'] as String? ?? '',
|
||||||
|
cachedDecoder: json['cachedDecoder'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineMoonshineModelConfig(preprocessor: $preprocessor, encoder: $encoder, uncachedDecoder: $uncachedDecoder, cachedDecoder: $cachedDecoder)';
|
return 'OfflineMoonshineModelConfig(preprocessor: $preprocessor, encoder: $encoder, uncachedDecoder: $uncachedDecoder, cachedDecoder: $cachedDecoder)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'preprocessor': preprocessor,
|
||||||
|
'encoder': encoder,
|
||||||
|
'uncachedDecoder': uncachedDecoder,
|
||||||
|
'cachedDecoder': cachedDecoder,
|
||||||
|
};
|
||||||
|
|
||||||
final String preprocessor;
|
final String preprocessor;
|
||||||
final String encoder;
|
final String encoder;
|
||||||
final String uncachedDecoder;
|
final String uncachedDecoder;
|
||||||
@@ -103,11 +181,21 @@ class OfflineMoonshineModelConfig {
|
|||||||
class OfflineTdnnModelConfig {
|
class OfflineTdnnModelConfig {
|
||||||
const OfflineTdnnModelConfig({this.model = ''});
|
const OfflineTdnnModelConfig({this.model = ''});
|
||||||
|
|
||||||
|
factory OfflineTdnnModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineTdnnModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineTdnnModelConfig(model: $model)';
|
return 'OfflineTdnnModelConfig(model: $model)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +206,26 @@ class OfflineSenseVoiceModelConfig {
|
|||||||
this.useInverseTextNormalization = false,
|
this.useInverseTextNormalization = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineSenseVoiceModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineSenseVoiceModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
language: json['language'] as String? ?? '',
|
||||||
|
useInverseTextNormalization:
|
||||||
|
json['useInverseTextNormalization'] as bool? ?? false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineSenseVoiceModelConfig(model: $model, language: $language, useInverseTextNormalization: $useInverseTextNormalization)';
|
return 'OfflineSenseVoiceModelConfig(model: $model, language: $language, useInverseTextNormalization: $useInverseTextNormalization)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
'language': language,
|
||||||
|
'useInverseTextNormalization': useInverseTextNormalization,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
final String language;
|
final String language;
|
||||||
final bool useInverseTextNormalization;
|
final bool useInverseTextNormalization;
|
||||||
@@ -131,11 +234,23 @@ class OfflineSenseVoiceModelConfig {
|
|||||||
class OfflineLMConfig {
|
class OfflineLMConfig {
|
||||||
const OfflineLMConfig({this.model = '', this.scale = 1.0});
|
const OfflineLMConfig({this.model = '', this.scale = 1.0});
|
||||||
|
|
||||||
|
factory OfflineLMConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineLMConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
scale: (json['scale'] as num?)?.toDouble() ?? 1.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineLMConfig(model: $model, scale: $scale)';
|
return 'OfflineLMConfig(model: $model, scale: $scale)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
'scale': scale,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
final double scale;
|
final double scale;
|
||||||
}
|
}
|
||||||
@@ -160,11 +275,75 @@ class OfflineModelConfig {
|
|||||||
this.telespeechCtc = '',
|
this.telespeechCtc = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineModelConfig(
|
||||||
|
transducer: json['transducer'] != null
|
||||||
|
? OfflineTransducerModelConfig.fromJson(
|
||||||
|
json['transducer'] as Map<String, dynamic>)
|
||||||
|
: const OfflineTransducerModelConfig(),
|
||||||
|
paraformer: json['paraformer'] != null
|
||||||
|
? OfflineParaformerModelConfig.fromJson(
|
||||||
|
json['paraformer'] as Map<String, dynamic>)
|
||||||
|
: const OfflineParaformerModelConfig(),
|
||||||
|
nemoCtc: json['nemoCtc'] != null
|
||||||
|
? OfflineNemoEncDecCtcModelConfig.fromJson(
|
||||||
|
json['nemoCtc'] as Map<String, dynamic>)
|
||||||
|
: const OfflineNemoEncDecCtcModelConfig(),
|
||||||
|
whisper: json['whisper'] != null
|
||||||
|
? OfflineWhisperModelConfig.fromJson(
|
||||||
|
json['whisper'] as Map<String, dynamic>)
|
||||||
|
: const OfflineWhisperModelConfig(),
|
||||||
|
tdnn: json['tdnn'] != null
|
||||||
|
? OfflineTdnnModelConfig.fromJson(
|
||||||
|
json['tdnn'] as Map<String, dynamic>)
|
||||||
|
: const OfflineTdnnModelConfig(),
|
||||||
|
senseVoice: json['senseVoice'] != null
|
||||||
|
? OfflineSenseVoiceModelConfig.fromJson(
|
||||||
|
json['senseVoice'] as Map<String, dynamic>)
|
||||||
|
: const OfflineSenseVoiceModelConfig(),
|
||||||
|
moonshine: json['moonshine'] != null
|
||||||
|
? OfflineMoonshineModelConfig.fromJson(
|
||||||
|
json['moonshine'] as Map<String, dynamic>)
|
||||||
|
: const OfflineMoonshineModelConfig(),
|
||||||
|
fireRedAsr: json['fireRedAsr'] != null
|
||||||
|
? OfflineFireRedAsrModelConfig.fromJson(
|
||||||
|
json['fireRedAsr'] as Map<String, dynamic>)
|
||||||
|
: const OfflineFireRedAsrModelConfig(),
|
||||||
|
tokens: json['tokens'] as String,
|
||||||
|
numThreads: json['numThreads'] as int? ?? 1,
|
||||||
|
debug: json['debug'] as bool? ?? true,
|
||||||
|
provider: json['provider'] as String? ?? 'cpu',
|
||||||
|
modelType: json['modelType'] as String? ?? '',
|
||||||
|
modelingUnit: json['modelingUnit'] as String? ?? '',
|
||||||
|
bpeVocab: json['bpeVocab'] as String? ?? '',
|
||||||
|
telespeechCtc: json['telespeechCtc'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineModelConfig(transducer: $transducer, paraformer: $paraformer, nemoCtc: $nemoCtc, whisper: $whisper, tdnn: $tdnn, senseVoice: $senseVoice, moonshine: $moonshine, fireRedAsr: $fireRedAsr, tokens: $tokens, numThreads: $numThreads, debug: $debug, provider: $provider, modelType: $modelType, modelingUnit: $modelingUnit, bpeVocab: $bpeVocab, telespeechCtc: $telespeechCtc)';
|
return 'OfflineModelConfig(transducer: $transducer, paraformer: $paraformer, nemoCtc: $nemoCtc, whisper: $whisper, tdnn: $tdnn, senseVoice: $senseVoice, moonshine: $moonshine, fireRedAsr: $fireRedAsr, tokens: $tokens, numThreads: $numThreads, debug: $debug, provider: $provider, modelType: $modelType, modelingUnit: $modelingUnit, bpeVocab: $bpeVocab, telespeechCtc: $telespeechCtc)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'transducer': transducer.toJson(),
|
||||||
|
'paraformer': paraformer.toJson(),
|
||||||
|
'nemoCtc': nemoCtc.toJson(),
|
||||||
|
'whisper': whisper.toJson(),
|
||||||
|
'tdnn': tdnn.toJson(),
|
||||||
|
'senseVoice': senseVoice.toJson(),
|
||||||
|
'moonshine': moonshine.toJson(),
|
||||||
|
'fireRedAsr': fireRedAsr.toJson(),
|
||||||
|
'tokens': tokens,
|
||||||
|
'numThreads': numThreads,
|
||||||
|
'debug': debug,
|
||||||
|
'provider': provider,
|
||||||
|
'modelType': modelType,
|
||||||
|
'modelingUnit': modelingUnit,
|
||||||
|
'bpeVocab': bpeVocab,
|
||||||
|
'telespeechCtc': telespeechCtc,
|
||||||
|
};
|
||||||
|
|
||||||
final OfflineTransducerModelConfig transducer;
|
final OfflineTransducerModelConfig transducer;
|
||||||
final OfflineParaformerModelConfig paraformer;
|
final OfflineParaformerModelConfig paraformer;
|
||||||
final OfflineNemoEncDecCtcModelConfig nemoCtc;
|
final OfflineNemoEncDecCtcModelConfig nemoCtc;
|
||||||
@@ -198,11 +377,43 @@ class OfflineRecognizerConfig {
|
|||||||
this.blankPenalty = 0.0,
|
this.blankPenalty = 0.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineRecognizerConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineRecognizerConfig(
|
||||||
|
feat: json['feat'] != null
|
||||||
|
? FeatureConfig.fromJson(json['feat'] as Map<String, dynamic>)
|
||||||
|
: const FeatureConfig(),
|
||||||
|
model: OfflineModelConfig.fromJson(json['model'] as Map<String, dynamic>),
|
||||||
|
lm: json['lm'] != null
|
||||||
|
? OfflineLMConfig.fromJson(json['lm'] as Map<String, dynamic>)
|
||||||
|
: const OfflineLMConfig(),
|
||||||
|
decodingMethod: json['decodingMethod'] as String? ?? 'greedy_search',
|
||||||
|
maxActivePaths: json['maxActivePaths'] as int? ?? 4,
|
||||||
|
hotwordsFile: json['hotwordsFile'] as String? ?? '',
|
||||||
|
hotwordsScore: (json['hotwordsScore'] as num?)?.toDouble() ?? 1.5,
|
||||||
|
ruleFsts: json['ruleFsts'] as String? ?? '',
|
||||||
|
ruleFars: json['ruleFars'] as String? ?? '',
|
||||||
|
blankPenalty: (json['blankPenalty'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineRecognizerConfig(feat: $feat, model: $model, lm: $lm, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ruleFsts: $ruleFsts, ruleFars: $ruleFars, blankPenalty: $blankPenalty)';
|
return 'OfflineRecognizerConfig(feat: $feat, model: $model, lm: $lm, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ruleFsts: $ruleFsts, ruleFars: $ruleFars, blankPenalty: $blankPenalty)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'feat': feat.toJson(),
|
||||||
|
'model': model.toJson(),
|
||||||
|
'lm': lm.toJson(),
|
||||||
|
'decodingMethod': decodingMethod,
|
||||||
|
'maxActivePaths': maxActivePaths,
|
||||||
|
'hotwordsFile': hotwordsFile,
|
||||||
|
'hotwordsScore': hotwordsScore,
|
||||||
|
'ruleFsts': ruleFsts,
|
||||||
|
'ruleFars': ruleFars,
|
||||||
|
'blankPenalty': blankPenalty,
|
||||||
|
};
|
||||||
|
|
||||||
final FeatureConfig feat;
|
final FeatureConfig feat;
|
||||||
final OfflineModelConfig model;
|
final OfflineModelConfig model;
|
||||||
final OfflineLMConfig lm;
|
final OfflineLMConfig lm;
|
||||||
@@ -229,11 +440,34 @@ class OfflineRecognizerResult {
|
|||||||
required this.emotion,
|
required this.emotion,
|
||||||
required this.event});
|
required this.event});
|
||||||
|
|
||||||
|
factory OfflineRecognizerResult.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineRecognizerResult(
|
||||||
|
text: json['text'] as String? ?? '',
|
||||||
|
tokens: (json['tokens'] as List?)?.map((e) => e as String).toList() ?? [],
|
||||||
|
timestamps: (json['timestamps'] as List?)
|
||||||
|
?.map((e) => (e as num).toDouble())
|
||||||
|
.toList() ??
|
||||||
|
[],
|
||||||
|
lang: json['lang'] as String? ?? '',
|
||||||
|
emotion: json['emotion'] as String? ?? '',
|
||||||
|
event: json['event'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps, lang: $lang, emotion: $emotion, event: $event)';
|
return 'OfflineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps, lang: $lang, emotion: $emotion, event: $event)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'text': text,
|
||||||
|
'tokens': tokens,
|
||||||
|
'timestamps': timestamps,
|
||||||
|
'lang': lang,
|
||||||
|
'emotion': emotion,
|
||||||
|
'event': event,
|
||||||
|
};
|
||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
final List<String> tokens;
|
final List<String> tokens;
|
||||||
final List<double> timestamps;
|
final List<double> timestamps;
|
||||||
@@ -305,8 +539,10 @@ class OfflineRecognizer {
|
|||||||
config.model.moonshine.cachedDecoder.toNativeUtf8();
|
config.model.moonshine.cachedDecoder.toNativeUtf8();
|
||||||
|
|
||||||
// FireRedAsr
|
// FireRedAsr
|
||||||
c.ref.model.fireRedAsr.encoder = config.model.fireRedAsr.encoder.toNativeUtf8();
|
c.ref.model.fireRedAsr.encoder =
|
||||||
c.ref.model.fireRedAsr.decoder = config.model.fireRedAsr.decoder.toNativeUtf8();
|
config.model.fireRedAsr.encoder.toNativeUtf8();
|
||||||
|
c.ref.model.fireRedAsr.decoder =
|
||||||
|
config.model.fireRedAsr.decoder.toNativeUtf8();
|
||||||
|
|
||||||
c.ref.model.tokens = config.model.tokens.toNativeUtf8();
|
c.ref.model.tokens = config.model.tokens.toNativeUtf8();
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,25 @@ class OfflineSpeakerDiarizationSegment {
|
|||||||
required this.speaker,
|
required this.speaker,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineSpeakerDiarizationSegment.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineSpeakerDiarizationSegment(
|
||||||
|
start: (json['start'] as num).toDouble(),
|
||||||
|
end: (json['end'] as num).toDouble(),
|
||||||
|
speaker: json['speaker'] as int,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineSpeakerDiarizationSegment(start: $start, end: $end, speaker: $speaker)';
|
return 'OfflineSpeakerDiarizationSegment(start: $start, end: $end, speaker: $speaker)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'start': start,
|
||||||
|
'end': end,
|
||||||
|
'speaker': speaker,
|
||||||
|
};
|
||||||
|
|
||||||
final double start;
|
final double start;
|
||||||
final double end;
|
final double end;
|
||||||
final int speaker;
|
final int speaker;
|
||||||
@@ -29,11 +43,22 @@ class OfflineSpeakerSegmentationPyannoteModelConfig {
|
|||||||
this.model = '',
|
this.model = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineSpeakerSegmentationPyannoteModelConfig.fromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return OfflineSpeakerSegmentationPyannoteModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineSpeakerSegmentationPyannoteModelConfig(model: $model)';
|
return 'OfflineSpeakerSegmentationPyannoteModelConfig(model: $model)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,11 +70,31 @@ class OfflineSpeakerSegmentationModelConfig {
|
|||||||
this.provider = 'cpu',
|
this.provider = 'cpu',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineSpeakerSegmentationModelConfig.fromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return OfflineSpeakerSegmentationModelConfig(
|
||||||
|
pyannote: json['pyannote'] != null
|
||||||
|
? OfflineSpeakerSegmentationPyannoteModelConfig.fromJson(
|
||||||
|
json['pyannote'] as Map<String, dynamic>)
|
||||||
|
: const OfflineSpeakerSegmentationPyannoteModelConfig(),
|
||||||
|
numThreads: json['numThreads'] as int? ?? 1,
|
||||||
|
debug: json['debug'] as bool? ?? true,
|
||||||
|
provider: json['provider'] as String? ?? 'cpu',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineSpeakerSegmentationModelConfig(pyannote: $pyannote, numThreads: $numThreads, debug: $debug, provider: $provider)';
|
return 'OfflineSpeakerSegmentationModelConfig(pyannote: $pyannote, numThreads: $numThreads, debug: $debug, provider: $provider)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'pyannote': pyannote.toJson(),
|
||||||
|
'numThreads': numThreads,
|
||||||
|
'debug': debug,
|
||||||
|
'provider': provider,
|
||||||
|
};
|
||||||
|
|
||||||
final OfflineSpeakerSegmentationPyannoteModelConfig pyannote;
|
final OfflineSpeakerSegmentationPyannoteModelConfig pyannote;
|
||||||
|
|
||||||
final int numThreads;
|
final int numThreads;
|
||||||
@@ -63,11 +108,23 @@ class FastClusteringConfig {
|
|||||||
this.threshold = 0.5,
|
this.threshold = 0.5,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory FastClusteringConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return FastClusteringConfig(
|
||||||
|
numClusters: json['numClusters'] as int? ?? -1,
|
||||||
|
threshold: (json['threshold'] as num?)?.toDouble() ?? 0.5,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'FastClusteringConfig(numClusters: $numClusters, threshold: $threshold)';
|
return 'FastClusteringConfig(numClusters: $numClusters, threshold: $threshold)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'numClusters': numClusters,
|
||||||
|
'threshold': threshold,
|
||||||
|
};
|
||||||
|
|
||||||
final int numClusters;
|
final int numClusters;
|
||||||
final double threshold;
|
final double threshold;
|
||||||
}
|
}
|
||||||
@@ -81,11 +138,38 @@ class OfflineSpeakerDiarizationConfig {
|
|||||||
this.minDurationOff = 0.5,
|
this.minDurationOff = 0.5,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineSpeakerDiarizationConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineSpeakerDiarizationConfig(
|
||||||
|
segmentation: json['segmentation'] != null
|
||||||
|
? OfflineSpeakerSegmentationModelConfig.fromJson(
|
||||||
|
json['segmentation'] as Map<String, dynamic>)
|
||||||
|
: const OfflineSpeakerSegmentationModelConfig(),
|
||||||
|
embedding: json['embedding'] != null
|
||||||
|
? SpeakerEmbeddingExtractorConfig.fromJson(
|
||||||
|
json['embedding'] as Map<String, dynamic>)
|
||||||
|
: const SpeakerEmbeddingExtractorConfig(model: ''),
|
||||||
|
clustering: json['clustering'] != null
|
||||||
|
? FastClusteringConfig.fromJson(
|
||||||
|
json['clustering'] as Map<String, dynamic>)
|
||||||
|
: const FastClusteringConfig(),
|
||||||
|
minDurationOn: (json['minDurationOn'] as num?)?.toDouble() ?? 0.2,
|
||||||
|
minDurationOff: (json['minDurationOff'] as num?)?.toDouble() ?? 0.5,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineSpeakerDiarizationConfig(segmentation: $segmentation, embedding: $embedding, clustering: $clustering, minDurationOn: $minDurationOn, minDurationOff: $minDurationOff)';
|
return 'OfflineSpeakerDiarizationConfig(segmentation: $segmentation, embedding: $embedding, clustering: $clustering, minDurationOn: $minDurationOn, minDurationOff: $minDurationOff)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'segmentation': segmentation.toJson(),
|
||||||
|
'embedding': embedding.toJson(),
|
||||||
|
'clustering': clustering.toJson(),
|
||||||
|
'minDurationOn': minDurationOn,
|
||||||
|
'minDurationOff': minDurationOff,
|
||||||
|
};
|
||||||
|
|
||||||
final OfflineSpeakerSegmentationModelConfig segmentation;
|
final OfflineSpeakerSegmentationModelConfig segmentation;
|
||||||
final SpeakerEmbeddingExtractorConfig embedding;
|
final SpeakerEmbeddingExtractorConfig embedding;
|
||||||
final FastClusteringConfig clustering;
|
final FastClusteringConfig clustering;
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ class OnlinePunctuationModelConfig {
|
|||||||
this.provider = 'cpu',
|
this.provider = 'cpu',
|
||||||
this.debug = true});
|
this.debug = true});
|
||||||
|
|
||||||
|
factory OnlinePunctuationModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlinePunctuationModelConfig(
|
||||||
|
cnnBiLstm: json['cnnBiLstm'],
|
||||||
|
bpeVocab: json['bpeVocab'],
|
||||||
|
numThreads: json['numThreads'],
|
||||||
|
provider: json['provider'],
|
||||||
|
debug: json['debug'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlinePunctuationModelConfig(cnnBiLstm: $cnnBiLstm, '
|
return 'OnlinePunctuationModelConfig(cnnBiLstm: $cnnBiLstm, '
|
||||||
@@ -18,6 +28,16 @@ class OnlinePunctuationModelConfig {
|
|||||||
'provider: $provider, debug: $debug)';
|
'provider: $provider, debug: $debug)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'cnnBiLstm': cnnBiLstm,
|
||||||
|
'bpeVocab': bpeVocab,
|
||||||
|
'numThreads': numThreads,
|
||||||
|
'provider': provider,
|
||||||
|
'debug': debug,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
final String cnnBiLstm;
|
final String cnnBiLstm;
|
||||||
final String bpeVocab;
|
final String bpeVocab;
|
||||||
final int numThreads;
|
final int numThreads;
|
||||||
@@ -30,11 +50,23 @@ class OnlinePunctuationConfig {
|
|||||||
required this.model,
|
required this.model,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OnlinePunctuationConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlinePunctuationConfig(
|
||||||
|
model: OnlinePunctuationModelConfig.fromJson(json['model']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlinePunctuationConfig(model: $model)';
|
return 'OnlinePunctuationConfig(model: $model)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'model': model.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
final OnlinePunctuationModelConfig model;
|
final OnlinePunctuationModelConfig model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,25 @@ class OnlineTransducerModelConfig {
|
|||||||
this.joiner = '',
|
this.joiner = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OnlineTransducerModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlineTransducerModelConfig(
|
||||||
|
encoder: json['encoder'] as String? ?? '',
|
||||||
|
decoder: json['decoder'] as String? ?? '',
|
||||||
|
joiner: json['joiner'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlineTransducerModelConfig(encoder: $encoder, decoder: $decoder, joiner: $joiner)';
|
return 'OnlineTransducerModelConfig(encoder: $encoder, decoder: $decoder, joiner: $joiner)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'encoder': encoder,
|
||||||
|
'decoder': decoder,
|
||||||
|
'joiner': joiner,
|
||||||
|
};
|
||||||
|
|
||||||
final String encoder;
|
final String encoder;
|
||||||
final String decoder;
|
final String decoder;
|
||||||
final String joiner;
|
final String joiner;
|
||||||
@@ -29,11 +43,23 @@ class OnlineTransducerModelConfig {
|
|||||||
class OnlineParaformerModelConfig {
|
class OnlineParaformerModelConfig {
|
||||||
const OnlineParaformerModelConfig({this.encoder = '', this.decoder = ''});
|
const OnlineParaformerModelConfig({this.encoder = '', this.decoder = ''});
|
||||||
|
|
||||||
|
factory OnlineParaformerModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlineParaformerModelConfig(
|
||||||
|
encoder: json['encoder'] as String? ?? '',
|
||||||
|
decoder: json['decoder'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlineParaformerModelConfig(encoder: $encoder, decoder: $decoder)';
|
return 'OnlineParaformerModelConfig(encoder: $encoder, decoder: $decoder)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'encoder': encoder,
|
||||||
|
'decoder': decoder,
|
||||||
|
};
|
||||||
|
|
||||||
final String encoder;
|
final String encoder;
|
||||||
final String decoder;
|
final String decoder;
|
||||||
}
|
}
|
||||||
@@ -41,11 +67,21 @@ class OnlineParaformerModelConfig {
|
|||||||
class OnlineZipformer2CtcModelConfig {
|
class OnlineZipformer2CtcModelConfig {
|
||||||
const OnlineZipformer2CtcModelConfig({this.model = ''});
|
const OnlineZipformer2CtcModelConfig({this.model = ''});
|
||||||
|
|
||||||
|
factory OnlineZipformer2CtcModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlineZipformer2CtcModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlineZipformer2CtcModelConfig(model: $model)';
|
return 'OnlineZipformer2CtcModelConfig(model: $model)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,11 +99,42 @@ class OnlineModelConfig {
|
|||||||
this.bpeVocab = '',
|
this.bpeVocab = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OnlineModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlineModelConfig(
|
||||||
|
transducer: OnlineTransducerModelConfig.fromJson(
|
||||||
|
json['transducer'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
paraformer: OnlineParaformerModelConfig.fromJson(
|
||||||
|
json['paraformer'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
zipformer2Ctc: OnlineZipformer2CtcModelConfig.fromJson(
|
||||||
|
json['zipformer2Ctc'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
tokens: json['tokens'] as String,
|
||||||
|
numThreads: json['numThreads'] as int? ?? 1,
|
||||||
|
provider: json['provider'] as String? ?? 'cpu',
|
||||||
|
debug: json['debug'] as bool? ?? true,
|
||||||
|
modelType: json['modelType'] as String? ?? '',
|
||||||
|
modelingUnit: json['modelingUnit'] as String? ?? '',
|
||||||
|
bpeVocab: json['bpeVocab'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlineModelConfig(transducer: $transducer, paraformer: $paraformer, zipformer2Ctc: $zipformer2Ctc, tokens: $tokens, numThreads: $numThreads, provider: $provider, debug: $debug, modelType: $modelType, modelingUnit: $modelingUnit, bpeVocab: $bpeVocab)';
|
return 'OnlineModelConfig(transducer: $transducer, paraformer: $paraformer, zipformer2Ctc: $zipformer2Ctc, tokens: $tokens, numThreads: $numThreads, provider: $provider, debug: $debug, modelType: $modelType, modelingUnit: $modelingUnit, bpeVocab: $bpeVocab)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'transducer': transducer.toJson(),
|
||||||
|
'paraformer': paraformer.toJson(),
|
||||||
|
'zipformer2Ctc': zipformer2Ctc.toJson(),
|
||||||
|
'tokens': tokens,
|
||||||
|
'numThreads': numThreads,
|
||||||
|
'provider': provider,
|
||||||
|
'debug': debug,
|
||||||
|
'modelType': modelType,
|
||||||
|
'modelingUnit': modelingUnit,
|
||||||
|
'bpeVocab': bpeVocab,
|
||||||
|
};
|
||||||
|
|
||||||
final OnlineTransducerModelConfig transducer;
|
final OnlineTransducerModelConfig transducer;
|
||||||
final OnlineParaformerModelConfig paraformer;
|
final OnlineParaformerModelConfig paraformer;
|
||||||
final OnlineZipformer2CtcModelConfig zipformer2Ctc;
|
final OnlineZipformer2CtcModelConfig zipformer2Ctc;
|
||||||
@@ -90,11 +157,23 @@ class OnlineModelConfig {
|
|||||||
class OnlineCtcFstDecoderConfig {
|
class OnlineCtcFstDecoderConfig {
|
||||||
const OnlineCtcFstDecoderConfig({this.graph = '', this.maxActive = 3000});
|
const OnlineCtcFstDecoderConfig({this.graph = '', this.maxActive = 3000});
|
||||||
|
|
||||||
|
factory OnlineCtcFstDecoderConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlineCtcFstDecoderConfig(
|
||||||
|
graph: json['graph'] as String? ?? '',
|
||||||
|
maxActive: json['maxActive'] as int? ?? 3000,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlineCtcFstDecoderConfig(graph: $graph, maxActive: $maxActive)';
|
return 'OnlineCtcFstDecoderConfig(graph: $graph, maxActive: $maxActive)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'graph': graph,
|
||||||
|
'maxActive': maxActive,
|
||||||
|
};
|
||||||
|
|
||||||
final String graph;
|
final String graph;
|
||||||
final int maxActive;
|
final int maxActive;
|
||||||
}
|
}
|
||||||
@@ -117,11 +196,52 @@ class OnlineRecognizerConfig {
|
|||||||
this.blankPenalty = 0.0,
|
this.blankPenalty = 0.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OnlineRecognizerConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlineRecognizerConfig(
|
||||||
|
feat: FeatureConfig.fromJson(
|
||||||
|
json['feat'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
model: OnlineModelConfig.fromJson(json['model'] as Map<String, dynamic>),
|
||||||
|
decodingMethod: json['decodingMethod'] as String? ?? 'greedy_search',
|
||||||
|
maxActivePaths: json['maxActivePaths'] as int? ?? 4,
|
||||||
|
enableEndpoint: json['enableEndpoint'] as bool? ?? true,
|
||||||
|
rule1MinTrailingSilence:
|
||||||
|
(json['rule1MinTrailingSilence'] as num?)?.toDouble() ?? 2.4,
|
||||||
|
rule2MinTrailingSilence:
|
||||||
|
(json['rule2MinTrailingSilence'] as num?)?.toDouble() ?? 1.2,
|
||||||
|
rule3MinUtteranceLength:
|
||||||
|
(json['rule3MinUtteranceLength'] as num?)?.toDouble() ?? 20.0,
|
||||||
|
hotwordsFile: json['hotwordsFile'] as String? ?? '',
|
||||||
|
hotwordsScore: (json['hotwordsScore'] as num?)?.toDouble() ?? 1.5,
|
||||||
|
ctcFstDecoderConfig: OnlineCtcFstDecoderConfig.fromJson(
|
||||||
|
json['ctcFstDecoderConfig'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
ruleFsts: json['ruleFsts'] as String? ?? '',
|
||||||
|
ruleFars: json['ruleFars'] as String? ?? '',
|
||||||
|
blankPenalty: (json['blankPenalty'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlineRecognizerConfig(feat: $feat, model: $model, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, enableEndpoint: $enableEndpoint, rule1MinTrailingSilence: $rule1MinTrailingSilence, rule2MinTrailingSilence: $rule2MinTrailingSilence, rule3MinUtteranceLength: $rule3MinUtteranceLength, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ctcFstDecoderConfig: $ctcFstDecoderConfig, ruleFsts: $ruleFsts, ruleFars: $ruleFars, blankPenalty: $blankPenalty)';
|
return 'OnlineRecognizerConfig(feat: $feat, model: $model, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, enableEndpoint: $enableEndpoint, rule1MinTrailingSilence: $rule1MinTrailingSilence, rule2MinTrailingSilence: $rule2MinTrailingSilence, rule3MinUtteranceLength: $rule3MinUtteranceLength, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ctcFstDecoderConfig: $ctcFstDecoderConfig, ruleFsts: $ruleFsts, ruleFars: $ruleFars, blankPenalty: $blankPenalty)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'feat': feat.toJson(),
|
||||||
|
'model': model.toJson(),
|
||||||
|
'decodingMethod': decodingMethod,
|
||||||
|
'maxActivePaths': maxActivePaths,
|
||||||
|
'enableEndpoint': enableEndpoint,
|
||||||
|
'rule1MinTrailingSilence': rule1MinTrailingSilence,
|
||||||
|
'rule2MinTrailingSilence': rule2MinTrailingSilence,
|
||||||
|
'rule3MinUtteranceLength': rule3MinUtteranceLength,
|
||||||
|
'hotwordsFile': hotwordsFile,
|
||||||
|
'hotwordsScore': hotwordsScore,
|
||||||
|
'ctcFstDecoderConfig': ctcFstDecoderConfig.toJson(),
|
||||||
|
'ruleFsts': ruleFsts,
|
||||||
|
'ruleFars': ruleFars,
|
||||||
|
'blankPenalty': blankPenalty,
|
||||||
|
};
|
||||||
|
|
||||||
final FeatureConfig feat;
|
final FeatureConfig feat;
|
||||||
final OnlineModelConfig model;
|
final OnlineModelConfig model;
|
||||||
final String decodingMethod;
|
final String decodingMethod;
|
||||||
@@ -151,11 +271,27 @@ class OnlineRecognizerResult {
|
|||||||
OnlineRecognizerResult(
|
OnlineRecognizerResult(
|
||||||
{required this.text, required this.tokens, required this.timestamps});
|
{required this.text, required this.tokens, required this.timestamps});
|
||||||
|
|
||||||
|
factory OnlineRecognizerResult.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OnlineRecognizerResult(
|
||||||
|
text: json['text'] as String,
|
||||||
|
tokens: List<String>.from(json['tokens'] as List),
|
||||||
|
timestamps: (json['timestamps'] as List)
|
||||||
|
.map<double>((e) => (e as num).toDouble())
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OnlineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps)';
|
return 'OnlineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'text': text,
|
||||||
|
'tokens': tokens,
|
||||||
|
'timestamps': timestamps,
|
||||||
|
};
|
||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
final List<String> tokens;
|
final List<String> tokens;
|
||||||
final List<double> timestamps;
|
final List<double> timestamps;
|
||||||
|
|||||||
@@ -13,11 +13,27 @@ class SpeakerEmbeddingExtractorConfig {
|
|||||||
this.debug = true,
|
this.debug = true,
|
||||||
this.provider = 'cpu'});
|
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
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SpeakerEmbeddingExtractorConfig(model: $model, numThreads: $numThreads, debug: $debug, provider: $provider)';
|
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 String model;
|
||||||
final int numThreads;
|
final int numThreads;
|
||||||
final bool debug;
|
final bool debug;
|
||||||
|
|||||||
@@ -18,11 +18,35 @@ class OfflineTtsVitsModelConfig {
|
|||||||
this.dictDir = '',
|
this.dictDir = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineTtsVitsModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineTtsVitsModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
lexicon: json['lexicon'] as String? ?? '',
|
||||||
|
tokens: json['tokens'] as String? ?? '',
|
||||||
|
dataDir: json['dataDir'] as String? ?? '',
|
||||||
|
noiseScale: (json['noiseScale'] as num?)?.toDouble() ?? 0.667,
|
||||||
|
noiseScaleW: (json['noiseScaleW'] as num?)?.toDouble() ?? 0.8,
|
||||||
|
lengthScale: (json['lengthScale'] as num?)?.toDouble() ?? 1.0,
|
||||||
|
dictDir: json['dictDir'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineTtsVitsModelConfig(model: $model, lexicon: $lexicon, tokens: $tokens, dataDir: $dataDir, noiseScale: $noiseScale, noiseScaleW: $noiseScaleW, lengthScale: $lengthScale, dictDir: $dictDir)';
|
return 'OfflineTtsVitsModelConfig(model: $model, lexicon: $lexicon, tokens: $tokens, dataDir: $dataDir, noiseScale: $noiseScale, noiseScaleW: $noiseScaleW, lengthScale: $lengthScale, dictDir: $dictDir)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
'lexicon': lexicon,
|
||||||
|
'tokens': tokens,
|
||||||
|
'dataDir': dataDir,
|
||||||
|
'noiseScale': noiseScale,
|
||||||
|
'noiseScaleW': noiseScaleW,
|
||||||
|
'lengthScale': lengthScale,
|
||||||
|
'dictDir': dictDir,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
final String lexicon;
|
final String lexicon;
|
||||||
final String tokens;
|
final String tokens;
|
||||||
@@ -45,11 +69,35 @@ class OfflineTtsMatchaModelConfig {
|
|||||||
this.dictDir = '',
|
this.dictDir = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineTtsMatchaModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineTtsMatchaModelConfig(
|
||||||
|
acousticModel: json['acousticModel'] as String? ?? '',
|
||||||
|
vocoder: json['vocoder'] as String? ?? '',
|
||||||
|
lexicon: json['lexicon'] as String? ?? '',
|
||||||
|
tokens: json['tokens'] as String? ?? '',
|
||||||
|
dataDir: json['dataDir'] as String? ?? '',
|
||||||
|
noiseScale: (json['noiseScale'] as num?)?.toDouble() ?? 0.667,
|
||||||
|
lengthScale: (json['lengthScale'] as num?)?.toDouble() ?? 1.0,
|
||||||
|
dictDir: json['dictDir'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineTtsMatchaModelConfig(acousticModel: $acousticModel, vocoder: $vocoder, lexicon: $lexicon, tokens: $tokens, dataDir: $dataDir, noiseScale: $noiseScale, lengthScale: $lengthScale, dictDir: $dictDir)';
|
return 'OfflineTtsMatchaModelConfig(acousticModel: $acousticModel, vocoder: $vocoder, lexicon: $lexicon, tokens: $tokens, dataDir: $dataDir, noiseScale: $noiseScale, lengthScale: $lengthScale, dictDir: $dictDir)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'acousticModel': acousticModel,
|
||||||
|
'vocoder': vocoder,
|
||||||
|
'lexicon': lexicon,
|
||||||
|
'tokens': tokens,
|
||||||
|
'dataDir': dataDir,
|
||||||
|
'noiseScale': noiseScale,
|
||||||
|
'lengthScale': lengthScale,
|
||||||
|
'dictDir': dictDir,
|
||||||
|
};
|
||||||
|
|
||||||
final String acousticModel;
|
final String acousticModel;
|
||||||
final String vocoder;
|
final String vocoder;
|
||||||
final String lexicon;
|
final String lexicon;
|
||||||
@@ -71,11 +119,33 @@ class OfflineTtsKokoroModelConfig {
|
|||||||
this.lexicon = '',
|
this.lexicon = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineTtsKokoroModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineTtsKokoroModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
voices: json['voices'] as String? ?? '',
|
||||||
|
tokens: json['tokens'] as String? ?? '',
|
||||||
|
dataDir: json['dataDir'] as String? ?? '',
|
||||||
|
lengthScale: (json['lengthScale'] as num?)?.toDouble() ?? 1.0,
|
||||||
|
dictDir: json['dictDir'] as String? ?? '',
|
||||||
|
lexicon: json['lexicon'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineTtsKokoroModelConfig(model: $model, voices: $voices, tokens: $tokens, dataDir: $dataDir, lengthScale: $lengthScale, dictDir: $dictDir, lexicon: $lexicon)';
|
return 'OfflineTtsKokoroModelConfig(model: $model, voices: $voices, tokens: $tokens, dataDir: $dataDir, lengthScale: $lengthScale, dictDir: $dictDir, lexicon: $lexicon)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
'voices': voices,
|
||||||
|
'tokens': tokens,
|
||||||
|
'dataDir': dataDir,
|
||||||
|
'lengthScale': lengthScale,
|
||||||
|
'dictDir': dictDir,
|
||||||
|
'lexicon': lexicon,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
final String voices;
|
final String voices;
|
||||||
final String tokens;
|
final String tokens;
|
||||||
@@ -95,11 +165,34 @@ class OfflineTtsModelConfig {
|
|||||||
this.provider = 'cpu',
|
this.provider = 'cpu',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineTtsModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineTtsModelConfig(
|
||||||
|
vits: OfflineTtsVitsModelConfig.fromJson(
|
||||||
|
json['vits'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
matcha: OfflineTtsMatchaModelConfig.fromJson(
|
||||||
|
json['matcha'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
kokoro: OfflineTtsKokoroModelConfig.fromJson(
|
||||||
|
json['kokoro'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
numThreads: json['numThreads'] as int? ?? 1,
|
||||||
|
debug: json['debug'] as bool? ?? true,
|
||||||
|
provider: json['provider'] as String? ?? 'cpu',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineTtsModelConfig(vits: $vits, matcha: $matcha, kokoro: $kokoro, numThreads: $numThreads, debug: $debug, provider: $provider)';
|
return 'OfflineTtsModelConfig(vits: $vits, matcha: $matcha, kokoro: $kokoro, numThreads: $numThreads, debug: $debug, provider: $provider)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'vits': vits.toJson(),
|
||||||
|
'matcha': matcha.toJson(),
|
||||||
|
'kokoro': kokoro.toJson(),
|
||||||
|
'numThreads': numThreads,
|
||||||
|
'debug': debug,
|
||||||
|
'provider': provider,
|
||||||
|
};
|
||||||
|
|
||||||
final OfflineTtsVitsModelConfig vits;
|
final OfflineTtsVitsModelConfig vits;
|
||||||
final OfflineTtsMatchaModelConfig matcha;
|
final OfflineTtsMatchaModelConfig matcha;
|
||||||
final OfflineTtsKokoroModelConfig kokoro;
|
final OfflineTtsKokoroModelConfig kokoro;
|
||||||
@@ -117,11 +210,30 @@ class OfflineTtsConfig {
|
|||||||
this.silenceScale = 0.2,
|
this.silenceScale = 0.2,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
factory OfflineTtsConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OfflineTtsConfig(
|
||||||
|
model:
|
||||||
|
OfflineTtsModelConfig.fromJson(json['model'] as Map<String, dynamic>),
|
||||||
|
ruleFsts: json['ruleFsts'] as String? ?? '',
|
||||||
|
maxNumSenetences: json['maxNumSenetences'] as int? ?? 1,
|
||||||
|
ruleFars: json['ruleFars'] as String? ?? '',
|
||||||
|
silenceScale: (json['silenceScale'] as num?)?.toDouble() ?? 0.2,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OfflineTtsConfig(model: $model, ruleFsts: $ruleFsts, maxNumSenetences: $maxNumSenetences, ruleFars: $ruleFars, silenceScale: $silenceScale)';
|
return 'OfflineTtsConfig(model: $model, ruleFsts: $ruleFsts, maxNumSenetences: $maxNumSenetences, ruleFars: $ruleFars, silenceScale: $silenceScale)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model.toJson(),
|
||||||
|
'ruleFsts': ruleFsts,
|
||||||
|
'maxNumSenetences': maxNumSenetences,
|
||||||
|
'ruleFars': ruleFars,
|
||||||
|
'silenceScale': silenceScale,
|
||||||
|
};
|
||||||
|
|
||||||
final OfflineTtsModelConfig model;
|
final OfflineTtsModelConfig model;
|
||||||
final String ruleFsts;
|
final String ruleFsts;
|
||||||
final int maxNumSenetences;
|
final int maxNumSenetences;
|
||||||
|
|||||||
@@ -14,11 +14,33 @@ class SileroVadModelConfig {
|
|||||||
this.windowSize = 512,
|
this.windowSize = 512,
|
||||||
this.maxSpeechDuration = 5.0});
|
this.maxSpeechDuration = 5.0});
|
||||||
|
|
||||||
|
factory SileroVadModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return SileroVadModelConfig(
|
||||||
|
model: json['model'] as String? ?? '',
|
||||||
|
threshold: (json['threshold'] as num?)?.toDouble() ?? 0.5,
|
||||||
|
minSilenceDuration:
|
||||||
|
(json['minSilenceDuration'] as num?)?.toDouble() ?? 0.5,
|
||||||
|
minSpeechDuration:
|
||||||
|
(json['minSpeechDuration'] as num?)?.toDouble() ?? 0.25,
|
||||||
|
windowSize: json['windowSize'] as int? ?? 512,
|
||||||
|
maxSpeechDuration: (json['maxSpeechDuration'] as num?)?.toDouble() ?? 5.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SileroVadModelConfig(model: $model, threshold: $threshold, minSilenceDuration: $minSilenceDuration, minSpeechDuration: $minSpeechDuration, windowSize: $windowSize, maxSpeechDuration: $maxSpeechDuration)';
|
return 'SileroVadModelConfig(model: $model, threshold: $threshold, minSilenceDuration: $minSilenceDuration, minSpeechDuration: $minSpeechDuration, windowSize: $windowSize, maxSpeechDuration: $maxSpeechDuration)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'model': model,
|
||||||
|
'threshold': threshold,
|
||||||
|
'minSilenceDuration': minSilenceDuration,
|
||||||
|
'minSpeechDuration': minSpeechDuration,
|
||||||
|
'windowSize': windowSize,
|
||||||
|
'maxSpeechDuration': maxSpeechDuration,
|
||||||
|
};
|
||||||
|
|
||||||
final String model;
|
final String model;
|
||||||
final double threshold;
|
final double threshold;
|
||||||
final double minSilenceDuration;
|
final double minSilenceDuration;
|
||||||
@@ -28,23 +50,43 @@ class SileroVadModelConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class VadModelConfig {
|
class VadModelConfig {
|
||||||
VadModelConfig(
|
VadModelConfig({
|
||||||
{this.sileroVad = const SileroVadModelConfig(),
|
this.sileroVad = const SileroVadModelConfig(),
|
||||||
this.sampleRate = 16000,
|
this.sampleRate = 16000,
|
||||||
this.numThreads = 1,
|
this.numThreads = 1,
|
||||||
this.provider = 'cpu',
|
this.provider = 'cpu',
|
||||||
this.debug = true});
|
this.debug = true,
|
||||||
|
});
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'VadModelConfig(sileroVad: $sileroVad, sampleRate: $sampleRate, numThreads: $numThreads, provider: $provider, debug: $debug)';
|
|
||||||
}
|
|
||||||
|
|
||||||
final SileroVadModelConfig sileroVad;
|
final SileroVadModelConfig sileroVad;
|
||||||
final int sampleRate;
|
final int sampleRate;
|
||||||
final int numThreads;
|
final int numThreads;
|
||||||
final String provider;
|
final String provider;
|
||||||
final bool debug;
|
final bool debug;
|
||||||
|
|
||||||
|
factory VadModelConfig.fromJson(Map<String, dynamic> json) {
|
||||||
|
return VadModelConfig(
|
||||||
|
sileroVad: SileroVadModelConfig.fromJson(
|
||||||
|
json['sileroVad'] as Map<String, dynamic>? ?? const {}),
|
||||||
|
sampleRate: json['sampleRate'] as int? ?? 16000,
|
||||||
|
numThreads: json['numThreads'] as int? ?? 1,
|
||||||
|
provider: json['provider'] as String? ?? 'cpu',
|
||||||
|
debug: json['debug'] as bool? ?? true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'sileroVad': sileroVad.toJson(),
|
||||||
|
'sampleRate': sampleRate,
|
||||||
|
'numThreads': numThreads,
|
||||||
|
'provider': provider,
|
||||||
|
'debug': debug,
|
||||||
|
};
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VadModelConfig(sileroVad: $sileroVad, sampleRate: $sampleRate, numThreads: $numThreads, provider: $provider, debug: $debug)';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpeechSegment {
|
class SpeechSegment {
|
||||||
|
|||||||
Reference in New Issue
Block a user