Add non-streaming ASR examples for Dart API (#1007)

This commit is contained in:
Fangjun Kuang
2024-06-14 18:40:16 +08:00
committed by GitHub
parent b1f08c0a20
commit d94506698d
35 changed files with 984 additions and 37 deletions

View File

@@ -102,11 +102,14 @@ class OfflineModelConfig {
this.debug = true,
this.provider = 'cpu',
this.modelType = '',
this.modelingUnit = '',
this.bpeVocab = '',
this.telespeechCtc = '',
});
@override
String toString() {
return 'OfflineModelConfig(transducer: $transducer, paraformer: $paraformer, nemoCtc: $nemoCtc, whisper: $whisper, tdnn: $tdnn, tokens: $tokens, numThreads: $numThreads, debug: $debug, provider: $provider, modelType: $modelType)';
return 'OfflineModelConfig(transducer: $transducer, paraformer: $paraformer, nemoCtc: $nemoCtc, whisper: $whisper, tdnn: $tdnn, tokens: $tokens, numThreads: $numThreads, debug: $debug, provider: $provider, modelType: $modelType, modelingUnit: $modelingUnit, bpeVocab: $bpeVocab, telespeechCtc: $telespeechCtc)';
}
final OfflineTransducerModelConfig transducer;
@@ -120,6 +123,9 @@ class OfflineModelConfig {
final bool debug;
final String provider;
final String modelType;
final String modelingUnit;
final String bpeVocab;
final String telespeechCtc;
}
class OfflineRecognizerConfig {
@@ -213,6 +219,9 @@ class OfflineRecognizer {
c.ref.model.debug = config.model.debug ? 1 : 0;
c.ref.model.provider = config.model.provider.toNativeUtf8();
c.ref.model.modelType = config.model.modelType.toNativeUtf8();
c.ref.model.modelingUnit = config.model.modelingUnit.toNativeUtf8();
c.ref.model.bpeVocab = config.model.bpeVocab.toNativeUtf8();
c.ref.model.telespeechCtc = config.model.telespeechCtc.toNativeUtf8();
c.ref.lm.model = config.lm.model.toNativeUtf8();
c.ref.lm.scale = config.lm.scale;
@@ -228,6 +237,9 @@ class OfflineRecognizer {
calloc.free(c.ref.hotwordsFile);
calloc.free(c.ref.decodingMethod);
calloc.free(c.ref.lm.model);
calloc.free(c.ref.model.telespeechCtc);
calloc.free(c.ref.model.bpeVocab);
calloc.free(c.ref.model.modelingUnit);
calloc.free(c.ref.model.modelType);
calloc.free(c.ref.model.provider);
calloc.free(c.ref.model.tokens);

View File

@@ -58,11 +58,13 @@ class OnlineModelConfig {
this.provider = 'cpu',
this.debug = true,
this.modelType = '',
this.modelingUnit = '',
this.bpeVocab = '',
});
@override
String toString() {
return 'OnlineModelConfig(transducer: $transducer, paraformer: $paraformer, zipformer2Ctc: $zipformer2Ctc, tokens: $tokens, numThreads: $numThreads, provider: $provider, debug: $debug, modelType: $modelType)';
return 'OnlineModelConfig(transducer: $transducer, paraformer: $paraformer, zipformer2Ctc: $zipformer2Ctc, tokens: $tokens, numThreads: $numThreads, provider: $provider, debug: $debug, modelType: $modelType, modelingUnit: $modelingUnit, bpeVocab: $bpeVocab)';
}
final OnlineTransducerModelConfig transducer;
@@ -78,6 +80,10 @@ class OnlineModelConfig {
final bool debug;
final String modelType;
final String modelingUnit;
final String bpeVocab;
}
class OnlineCtcFstDecoderConfig {
@@ -180,6 +186,8 @@ class OnlineRecognizer {
c.ref.model.provider = config.model.provider.toNativeUtf8();
c.ref.model.debug = config.model.debug ? 1 : 0;
c.ref.model.modelType = config.model.modelType.toNativeUtf8();
c.ref.model.modelingUnit = config.model.modelingUnit.toNativeUtf8();
c.ref.model.bpeVocab = config.model.bpeVocab.toNativeUtf8();
c.ref.decodingMethod = config.decodingMethod.toNativeUtf8();
c.ref.maxActivePaths = config.maxActivePaths;
@@ -199,6 +207,8 @@ class OnlineRecognizer {
calloc.free(c.ref.ctcFstDecoderConfig.graph);
calloc.free(c.ref.hotwordsFile);
calloc.free(c.ref.decodingMethod);
calloc.free(c.ref.model.bpeVocab);
calloc.free(c.ref.model.modelingUnit);
calloc.free(c.ref.model.modelType);
calloc.free(c.ref.model.provider);
calloc.free(c.ref.model.tokens);

View File

@@ -63,6 +63,9 @@ final class SherpaOnnxOfflineModelConfig extends Struct {
external Pointer<Utf8> provider;
external Pointer<Utf8> modelType;
external Pointer<Utf8> modelingUnit;
external Pointer<Utf8> bpeVocab;
external Pointer<Utf8> telespeechCtc;
}
final class SherpaOnnxOfflineRecognizerConfig extends Struct {
@@ -111,6 +114,10 @@ final class SherpaOnnxOnlineModelConfig extends Struct {
external int debug;
external Pointer<Utf8> modelType;
external Pointer<Utf8> modelingUnit;
external Pointer<Utf8> bpeVocab;
}
final class SherpaOnnxOnlineCtcFstDecoderConfig extends Struct {

View File

@@ -17,7 +17,7 @@ topics:
- voice-activity-detection
# remember to change the version in macos/sherpa_onnx.podspec
version: 0.0.2
version: 1.9.29
homepage: https://github.com/k2-fsa/sherpa-onnx