Fangjun Kuang
Committed by GitHub

Add streaming ASR examples for Dart API (#1009)

正在显示 30 个修改的文件 包含 1021 行增加2 行删除
@@ -4,6 +4,30 @@ set -ex @@ -4,6 +4,30 @@ set -ex
4 4
5 cd dart-api-examples 5 cd dart-api-examples
6 6
  7 +pushd streaming-asr
  8 +
  9 +echo '----------streaming zipformer ctc HLG----------'
  10 +./run-zipformer-ctc-hlg.sh
  11 +rm -rf sherpa-onnx-*
  12 +
  13 +echo '----------streaming zipformer ctc----------'
  14 +./run-zipformer-ctc.sh
  15 +rm -rf sherpa-onnx-*
  16 +
  17 +echo '----------streaming zipformer transducer----------'
  18 +./run-zipformer-transducer.sh
  19 +rm -rf sherpa-onnx-*
  20 +
  21 +echo '----------streaming NeMo transducer----------'
  22 +./run-nemo-transducer.sh
  23 +rm -rf sherpa-onnx-*
  24 +
  25 +echo '----------streaming paraformer----------'
  26 +./run-paraformer.sh
  27 +rm -rf sherpa-onnx-*
  28 +
  29 +popd # streaming-asr
  30 +
7 pushd non-streaming-asr 31 pushd non-streaming-asr
8 32
9 echo '----------VAD with paraformer----------' 33 echo '----------VAD with paraformer----------'
@@ -34,7 +58,7 @@ echo '----------zipformer transducer----------' @@ -34,7 +58,7 @@ echo '----------zipformer transducer----------'
34 ./run-zipformer-transducer.sh 58 ./run-zipformer-transducer.sh
35 rm -rf sherpa-onnx-* 59 rm -rf sherpa-onnx-*
36 60
37 -popd 61 +popd # non-streaming-asr
38 62
39 pushd vad 63 pushd vad
40 ./run.sh 64 ./run.sh
@@ -6,12 +6,14 @@ on: @@ -6,12 +6,14 @@ on:
6 - master 6 - master
7 paths: 7 paths:
8 - '.github/workflows/test-dart.yaml' 8 - '.github/workflows/test-dart.yaml'
  9 + - '.github/scripts/test-dart.sh'
9 - 'dart-api-examples/**' 10 - 'dart-api-examples/**'
10 pull_request: 11 pull_request:
11 branches: 12 branches:
12 - master 13 - master
13 paths: 14 paths:
14 - '.github/workflows/test-dart.yaml' 15 - '.github/workflows/test-dart.yaml'
  16 + - '.github/scripts/test-dart.sh'
15 - 'dart-api-examples/**' 17 - 'dart-api-examples/**'
16 18
17 workflow_dispatch: 19 workflow_dispatch:
@@ -89,5 +91,6 @@ jobs: @@ -89,5 +91,6 @@ jobs:
89 run: | 91 run: |
90 cp scripts/dart/vad-pubspec.yaml dart-api-examples/vad/pubspec.yaml 92 cp scripts/dart/vad-pubspec.yaml dart-api-examples/vad/pubspec.yaml
91 cp scripts/dart/non-streaming-asr-pubspec.yaml dart-api-examples/non-streaming-asr/pubspec.yaml 93 cp scripts/dart/non-streaming-asr-pubspec.yaml dart-api-examples/non-streaming-asr/pubspec.yaml
  94 + cp scripts/dart/streaming-asr-pubspec.yaml dart-api-examples/streaming-asr/pubspec.yaml
92 95
93 .github/scripts/test-dart.sh 96 .github/scripts/test-dart.sh
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:typed_data'; 3 import 'dart:typed_data';
3 4
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:typed_data'; 3 import 'dart:typed_data';
3 4
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:typed_data'; 3 import 'dart:typed_data';
3 4
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:typed_data'; 3 import 'dart:typed_data';
3 4
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:typed_data'; 3 import 'dart:typed_data';
3 4
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:typed_data'; 3 import 'dart:typed_data';
3 4
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:typed_data'; 3 import 'dart:typed_data';
3 4
  1 +# https://dart.dev/guides/libraries/private-files
  2 +# Created by `dart pub`
  3 +.dart_tool/
  1 +## 1.0.0
  2 +
  3 +- Initial version.
  1 +# Introduction
  2 +
  3 +This folder contains examples for streaming ASR with Dart API.
  4 +| File | Description|
  5 +|------|------------|
  6 +|[./bin/nemo-transducer.dart](./bin/nemo-transducer.dart)| Use a NeMo transducer model for speech recognition. See [./run-nemo-transducer.sh](./run-nemo-transducer.sh)|
  7 +|[./bin/paraformer.dart](./bin/paraformer.dart)| Use a Paraformer model for speech recognition. See [./run-paraformer.sh](./run-paraformer.sh)|
  8 +|[./bin/zipformer-ctc-hlg.dart](./bin/zipformer-ctc-hlg.dart)| Use a Zipformer CTC model with HLG graph for speech recognition. See [./run-zipformer-ctc-hlg.sh](./run-zipformer-ctc-hlg.sh)|
  9 +|[./bin/zipformer-ctc.dart](./bin/zipformer-ctc.dart)| Use a Zipformer CTC model for speech recognition. See [./run-zipformer-ctc.sh](./run-zipformer-ctc.sh)|
  10 +|[./bin/zipformer-transducer.dart](./bin/zipformer-transducer.dart)| Use a Zipformer transducer model for speech recognition. See [./run-zipformer-transducer.sh](./run-zipformer-transducer.sh)|
  11 +
  1 +# This file configures the static analysis results for your project (errors,
  2 +# warnings, and lints).
  3 +#
  4 +# This enables the 'recommended' set of lints from `package:lints`.
  5 +# This set helps identify many issues that may lead to problems when running
  6 +# or consuming Dart code, and enforces writing Dart using a single, idiomatic
  7 +# style and format.
  8 +#
  9 +# If you want a smaller set of lints you can change this to specify
  10 +# 'package:lints/core.yaml'. These are just the most critical lints
  11 +# (the recommended set includes the core lints).
  12 +# The core lints are also what is used by pub.dev for scoring packages.
  13 +
  14 +include: package:lints/recommended.yaml
  15 +
  16 +# Uncomment the following section to specify additional rules.
  17 +
  18 +# linter:
  19 +# rules:
  20 +# - camel_case_types
  21 +
  22 +# analyzer:
  23 +# exclude:
  24 +# - path/to/excluded/files/**
  25 +
  26 +# For more information about the core and recommended set of lints, see
  27 +# https://dart.dev/go/core-lints
  28 +
  29 +# For additional information about configuring this file, see
  30 +# https://dart.dev/guides/language/analysis-options
  1 +// Copyright (c) 2024 Xiaomi Corporation
  2 +import 'dart:io';
  3 +import 'dart:typed_data';
  4 +
  5 +import 'package:args/args.dart';
  6 +import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
  7 +
  8 +import './init.dart';
  9 +
  10 +void main(List<String> arguments) async {
  11 + await initSherpaOnnx();
  12 +
  13 + final parser = ArgParser()
  14 + ..addOption('encoder', help: 'Path to the encoder model')
  15 + ..addOption('decoder', help: 'Path to decoder model')
  16 + ..addOption('tokens', help: 'Path to tokens.txt')
  17 + ..addOption('input-wav', help: 'Path to input.wav to transcribe');
  18 +
  19 + final res = parser.parse(arguments);
  20 + if (res['encoder'] == null ||
  21 + res['decoder'] == null ||
  22 + res['tokens'] == null ||
  23 + res['input-wav'] == null) {
  24 + print(parser.usage);
  25 + exit(1);
  26 + }
  27 +
  28 + final encoder = res['encoder'] as String;
  29 + final decoder = res['decoder'] as String;
  30 + final tokens = res['tokens'] as String;
  31 + final inputWav = res['input-wav'] as String;
  32 +
  33 + final paraformer = sherpa_onnx.OnlineParaformerModelConfig(
  34 + encoder: encoder,
  35 + decoder: decoder,
  36 + );
  37 +
  38 + final modelConfig = sherpa_onnx.OnlineModelConfig(
  39 + paraformer: paraformer,
  40 + tokens: tokens,
  41 + debug: true,
  42 + numThreads: 1,
  43 + );
  44 + final config = sherpa_onnx.OnlineRecognizerConfig(model: modelConfig);
  45 + final recognizer = sherpa_onnx.OnlineRecognizer(config);
  46 +
  47 + final waveData = sherpa_onnx.readWave(inputWav);
  48 + final stream = recognizer.createStream();
  49 +
  50 + // simulate streaming. You can choose an arbitrary chunk size.
  51 + // chunkSize of a single sample is also ok, i.e, chunkSize = 1
  52 + final chunkSize = 1600; // 0.1 second for 16kHz
  53 + final numChunks = waveData.samples.length ~/ chunkSize;
  54 +
  55 + var last = '';
  56 + for (int i = 0; i != numChunks; ++i) {
  57 + int start = i * chunkSize;
  58 + stream.acceptWaveform(
  59 + samples:
  60 + Float32List.sublistView(waveData.samples, start, start + chunkSize),
  61 + sampleRate: waveData.sampleRate,
  62 + );
  63 + while (recognizer.isReady(stream)) {
  64 + recognizer.decode(stream);
  65 + }
  66 + final result = recognizer.getResult(stream);
  67 + if (result.text != last && result.text != '') {
  68 + last = result.text;
  69 + print(last);
  70 + }
  71 + }
  72 +
  73 + // 0.5 seconds, assume sampleRate is 16kHz
  74 + final tailPaddings = Float32List(8000);
  75 + stream.acceptWaveform(
  76 + samples: tailPaddings,
  77 + sampleRate: waveData.sampleRate,
  78 + );
  79 +
  80 + while (recognizer.isReady(stream)) {
  81 + recognizer.decode(stream);
  82 + }
  83 +
  84 + final result = recognizer.getResult(stream);
  85 +
  86 + if (result.text != '') {
  87 + print(result.text);
  88 + }
  89 +
  90 + stream.free();
  91 + recognizer.free();
  92 +}
  1 +// Copyright (c) 2024 Xiaomi Corporation
  2 +import 'dart:io';
  3 +import 'dart:typed_data';
  4 +
  5 +import 'package:args/args.dart';
  6 +import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
  7 +
  8 +import './init.dart';
  9 +
  10 +void main(List<String> arguments) async {
  11 + await initSherpaOnnx();
  12 +
  13 + final parser = ArgParser()
  14 + ..addOption('model', help: 'Path to the model')
  15 + ..addOption('hlg', help: 'Path to HLG.fst')
  16 + ..addOption('tokens', help: 'Path to tokens.txt')
  17 + ..addOption('input-wav', help: 'Path to input.wav to transcribe');
  18 +
  19 + final res = parser.parse(arguments);
  20 + if (res['model'] == null ||
  21 + res['hlg'] == null ||
  22 + res['tokens'] == null ||
  23 + res['input-wav'] == null) {
  24 + print(parser.usage);
  25 + exit(1);
  26 + }
  27 +
  28 + final model = res['model'] as String;
  29 + final hlg = res['hlg'] as String;
  30 + final tokens = res['tokens'] as String;
  31 + final inputWav = res['input-wav'] as String;
  32 +
  33 + final ctc = sherpa_onnx.OnlineZipformer2CtcModelConfig(
  34 + model: model,
  35 + );
  36 +
  37 + final modelConfig = sherpa_onnx.OnlineModelConfig(
  38 + zipformer2Ctc: ctc,
  39 + tokens: tokens,
  40 + debug: true,
  41 + numThreads: 1,
  42 + );
  43 + final config = sherpa_onnx.OnlineRecognizerConfig(
  44 + model: modelConfig,
  45 + ctcFstDecoderConfig: sherpa_onnx.OnlineCtcFstDecoderConfig(graph: hlg),
  46 + );
  47 + final recognizer = sherpa_onnx.OnlineRecognizer(config);
  48 +
  49 + final waveData = sherpa_onnx.readWave(inputWav);
  50 + final stream = recognizer.createStream();
  51 +
  52 + // simulate streaming. You can choose an arbitrary chunk size.
  53 + // chunkSize of a single sample is also ok, i.e, chunkSize = 1
  54 + final chunkSize = 1600; // 0.1 second for 16kHz
  55 + final numChunks = waveData.samples.length ~/ chunkSize;
  56 +
  57 + var last = '';
  58 + for (int i = 0; i != numChunks; ++i) {
  59 + int start = i * chunkSize;
  60 + stream.acceptWaveform(
  61 + samples:
  62 + Float32List.sublistView(waveData.samples, start, start + chunkSize),
  63 + sampleRate: waveData.sampleRate,
  64 + );
  65 + while (recognizer.isReady(stream)) {
  66 + recognizer.decode(stream);
  67 + }
  68 + final result = recognizer.getResult(stream);
  69 + if (result.text != last && result.text != '') {
  70 + last = result.text;
  71 + print(last);
  72 + }
  73 + }
  74 +
  75 + // 0.5 seconds, assume sampleRate is 16kHz
  76 + final tailPaddings = Float32List(8000);
  77 + stream.acceptWaveform(
  78 + samples: tailPaddings,
  79 + sampleRate: waveData.sampleRate,
  80 + );
  81 +
  82 + while (recognizer.isReady(stream)) {
  83 + recognizer.decode(stream);
  84 + }
  85 +
  86 + final result = recognizer.getResult(stream);
  87 +
  88 + if (result.text != '') {
  89 + print(result.text);
  90 + }
  91 +
  92 + stream.free();
  93 + recognizer.free();
  94 +}
  1 +// Copyright (c) 2024 Xiaomi Corporation
  2 +import 'dart:io';
  3 +import 'dart:typed_data';
  4 +
  5 +import 'package:args/args.dart';
  6 +import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
  7 +
  8 +import './init.dart';
  9 +
  10 +void main(List<String> arguments) async {
  11 + await initSherpaOnnx();
  12 +
  13 + final parser = ArgParser()
  14 + ..addOption('model', help: 'Path to the model')
  15 + ..addOption('tokens', help: 'Path to tokens.txt')
  16 + ..addOption('input-wav', help: 'Path to input.wav to transcribe');
  17 +
  18 + final res = parser.parse(arguments);
  19 + if (res['model'] == null ||
  20 + res['tokens'] == null ||
  21 + res['input-wav'] == null) {
  22 + print(parser.usage);
  23 + exit(1);
  24 + }
  25 +
  26 + final model = res['model'] as String;
  27 + final tokens = res['tokens'] as String;
  28 + final inputWav = res['input-wav'] as String;
  29 +
  30 + final ctc = sherpa_onnx.OnlineZipformer2CtcModelConfig(
  31 + model: model,
  32 + );
  33 +
  34 + final modelConfig = sherpa_onnx.OnlineModelConfig(
  35 + zipformer2Ctc: ctc,
  36 + tokens: tokens,
  37 + debug: true,
  38 + numThreads: 1,
  39 + );
  40 + final config = sherpa_onnx.OnlineRecognizerConfig(model: modelConfig);
  41 + final recognizer = sherpa_onnx.OnlineRecognizer(config);
  42 +
  43 + final waveData = sherpa_onnx.readWave(inputWav);
  44 + final stream = recognizer.createStream();
  45 +
  46 + // simulate streaming. You can choose an arbitrary chunk size.
  47 + // chunkSize of a single sample is also ok, i.e, chunkSize = 1
  48 + final chunkSize = 1600; // 0.1 second for 16kHz
  49 + final numChunks = waveData.samples.length ~/ chunkSize;
  50 +
  51 + var last = '';
  52 + for (int i = 0; i != numChunks; ++i) {
  53 + int start = i * chunkSize;
  54 + stream.acceptWaveform(
  55 + samples:
  56 + Float32List.sublistView(waveData.samples, start, start + chunkSize),
  57 + sampleRate: waveData.sampleRate,
  58 + );
  59 + while (recognizer.isReady(stream)) {
  60 + recognizer.decode(stream);
  61 + }
  62 + final result = recognizer.getResult(stream);
  63 + if (result.text != last && result.text != '') {
  64 + last = result.text;
  65 + print(last);
  66 + }
  67 + }
  68 +
  69 + // 0.5 seconds, assume sampleRate is 16kHz
  70 + final tailPaddings = Float32List(8000);
  71 + stream.acceptWaveform(
  72 + samples: tailPaddings,
  73 + sampleRate: waveData.sampleRate,
  74 + );
  75 +
  76 + while (recognizer.isReady(stream)) {
  77 + recognizer.decode(stream);
  78 + }
  79 +
  80 + final result = recognizer.getResult(stream);
  81 +
  82 + if (result.text != '') {
  83 + print(result.text);
  84 + }
  85 +
  86 + stream.free();
  87 + recognizer.free();
  88 +}
  1 +// Copyright (c) 2024 Xiaomi Corporation
  2 +import 'dart:io';
  3 +import 'dart:typed_data';
  4 +
  5 +import 'package:args/args.dart';
  6 +import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
  7 +
  8 +import './init.dart';
  9 +
  10 +void main(List<String> arguments) async {
  11 + await initSherpaOnnx();
  12 +
  13 + final parser = ArgParser()
  14 + ..addOption('encoder', help: 'Path to the encoder model')
  15 + ..addOption('decoder', help: 'Path to decoder model')
  16 + ..addOption('joiner', help: 'Path to joiner model')
  17 + ..addOption('tokens', help: 'Path to tokens.txt')
  18 + ..addOption('input-wav', help: 'Path to input.wav to transcribe');
  19 +
  20 + final res = parser.parse(arguments);
  21 + if (res['encoder'] == null ||
  22 + res['decoder'] == null ||
  23 + res['joiner'] == null ||
  24 + res['tokens'] == null ||
  25 + res['input-wav'] == null) {
  26 + print(parser.usage);
  27 + exit(1);
  28 + }
  29 +
  30 + final encoder = res['encoder'] as String;
  31 + final decoder = res['decoder'] as String;
  32 + final joiner = res['joiner'] as String;
  33 + final tokens = res['tokens'] as String;
  34 + final inputWav = res['input-wav'] as String;
  35 +
  36 + final transducer = sherpa_onnx.OnlineTransducerModelConfig(
  37 + encoder: encoder,
  38 + decoder: decoder,
  39 + joiner: joiner,
  40 + );
  41 +
  42 + final modelConfig = sherpa_onnx.OnlineModelConfig(
  43 + transducer: transducer,
  44 + tokens: tokens,
  45 + debug: true,
  46 + numThreads: 1,
  47 + );
  48 + final config = sherpa_onnx.OnlineRecognizerConfig(model: modelConfig);
  49 + final recognizer = sherpa_onnx.OnlineRecognizer(config);
  50 +
  51 + final waveData = sherpa_onnx.readWave(inputWav);
  52 + final stream = recognizer.createStream();
  53 +
  54 + // simulate streaming. You can choose an arbitrary chunk size.
  55 + // chunkSize of a single sample is also ok, i.e, chunkSize = 1
  56 + final chunkSize = 1600; // 0.1 second for 16kHz
  57 + final numChunks = waveData.samples.length ~/ chunkSize;
  58 +
  59 + var last = '';
  60 + for (int i = 0; i != numChunks; ++i) {
  61 + int start = i * chunkSize;
  62 + stream.acceptWaveform(
  63 + samples:
  64 + Float32List.sublistView(waveData.samples, start, start + chunkSize),
  65 + sampleRate: waveData.sampleRate,
  66 + );
  67 + while (recognizer.isReady(stream)) {
  68 + recognizer.decode(stream);
  69 + }
  70 + final result = recognizer.getResult(stream);
  71 + if (result.text != last && result.text != '') {
  72 + last = result.text;
  73 + print(last);
  74 + }
  75 + }
  76 +
  77 + // 0.5 seconds, assume sampleRate is 16kHz
  78 + final tailPaddings = Float32List(8000);
  79 + stream.acceptWaveform(
  80 + samples: tailPaddings,
  81 + sampleRate: waveData.sampleRate,
  82 + );
  83 +
  84 + while (recognizer.isReady(stream)) {
  85 + recognizer.decode(stream);
  86 + }
  87 +
  88 + final result = recognizer.getResult(stream);
  89 +
  90 + if (result.text != '') {
  91 + print(result.text);
  92 + }
  93 +
  94 + stream.free();
  95 + recognizer.free();
  96 +}
  1 +# Generated by pub
  2 +# See https://dart.dev/tools/pub/glossary#lockfile
  3 +packages:
  4 + _fe_analyzer_shared:
  5 + dependency: transitive
  6 + description:
  7 + name: _fe_analyzer_shared
  8 + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7"
  9 + url: "https://pub.dev"
  10 + source: hosted
  11 + version: "67.0.0"
  12 + analyzer:
  13 + dependency: transitive
  14 + description:
  15 + name: analyzer
  16 + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
  17 + url: "https://pub.dev"
  18 + source: hosted
  19 + version: "6.4.1"
  20 + args:
  21 + dependency: "direct main"
  22 + description:
  23 + name: args
  24 + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
  25 + url: "https://pub.dev"
  26 + source: hosted
  27 + version: "2.5.0"
  28 + async:
  29 + dependency: transitive
  30 + description:
  31 + name: async
  32 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
  33 + url: "https://pub.dev"
  34 + source: hosted
  35 + version: "2.11.0"
  36 + boolean_selector:
  37 + dependency: transitive
  38 + description:
  39 + name: boolean_selector
  40 + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
  41 + url: "https://pub.dev"
  42 + source: hosted
  43 + version: "2.1.1"
  44 + characters:
  45 + dependency: transitive
  46 + description:
  47 + name: characters
  48 + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
  49 + url: "https://pub.dev"
  50 + source: hosted
  51 + version: "1.3.0"
  52 + collection:
  53 + dependency: transitive
  54 + description:
  55 + name: collection
  56 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
  57 + url: "https://pub.dev"
  58 + source: hosted
  59 + version: "1.18.0"
  60 + convert:
  61 + dependency: transitive
  62 + description:
  63 + name: convert
  64 + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
  65 + url: "https://pub.dev"
  66 + source: hosted
  67 + version: "3.1.1"
  68 + coverage:
  69 + dependency: transitive
  70 + description:
  71 + name: coverage
  72 + sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e"
  73 + url: "https://pub.dev"
  74 + source: hosted
  75 + version: "1.8.0"
  76 + crypto:
  77 + dependency: transitive
  78 + description:
  79 + name: crypto
  80 + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
  81 + url: "https://pub.dev"
  82 + source: hosted
  83 + version: "3.0.3"
  84 + ffi:
  85 + dependency: transitive
  86 + description:
  87 + name: ffi
  88 + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
  89 + url: "https://pub.dev"
  90 + source: hosted
  91 + version: "2.1.2"
  92 + file:
  93 + dependency: transitive
  94 + description:
  95 + name: file
  96 + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
  97 + url: "https://pub.dev"
  98 + source: hosted
  99 + version: "7.0.0"
  100 + flutter:
  101 + dependency: transitive
  102 + description: flutter
  103 + source: sdk
  104 + version: "0.0.0"
  105 + frontend_server_client:
  106 + dependency: transitive
  107 + description:
  108 + name: frontend_server_client
  109 + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
  110 + url: "https://pub.dev"
  111 + source: hosted
  112 + version: "4.0.0"
  113 + glob:
  114 + dependency: transitive
  115 + description:
  116 + name: glob
  117 + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
  118 + url: "https://pub.dev"
  119 + source: hosted
  120 + version: "2.1.2"
  121 + http_multi_server:
  122 + dependency: transitive
  123 + description:
  124 + name: http_multi_server
  125 + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
  126 + url: "https://pub.dev"
  127 + source: hosted
  128 + version: "3.2.1"
  129 + http_parser:
  130 + dependency: transitive
  131 + description:
  132 + name: http_parser
  133 + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
  134 + url: "https://pub.dev"
  135 + source: hosted
  136 + version: "4.0.2"
  137 + io:
  138 + dependency: transitive
  139 + description:
  140 + name: io
  141 + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
  142 + url: "https://pub.dev"
  143 + source: hosted
  144 + version: "1.0.4"
  145 + js:
  146 + dependency: transitive
  147 + description:
  148 + name: js
  149 + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
  150 + url: "https://pub.dev"
  151 + source: hosted
  152 + version: "0.7.1"
  153 + lints:
  154 + dependency: "direct dev"
  155 + description:
  156 + name: lints
  157 + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
  158 + url: "https://pub.dev"
  159 + source: hosted
  160 + version: "3.0.0"
  161 + logging:
  162 + dependency: transitive
  163 + description:
  164 + name: logging
  165 + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
  166 + url: "https://pub.dev"
  167 + source: hosted
  168 + version: "1.2.0"
  169 + matcher:
  170 + dependency: transitive
  171 + description:
  172 + name: matcher
  173 + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
  174 + url: "https://pub.dev"
  175 + source: hosted
  176 + version: "0.12.16+1"
  177 + material_color_utilities:
  178 + dependency: transitive
  179 + description:
  180 + name: material_color_utilities
  181 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
  182 + url: "https://pub.dev"
  183 + source: hosted
  184 + version: "0.8.0"
  185 + meta:
  186 + dependency: transitive
  187 + description:
  188 + name: meta
  189 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
  190 + url: "https://pub.dev"
  191 + source: hosted
  192 + version: "1.12.0"
  193 + mime:
  194 + dependency: transitive
  195 + description:
  196 + name: mime
  197 + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2"
  198 + url: "https://pub.dev"
  199 + source: hosted
  200 + version: "1.0.5"
  201 + node_preamble:
  202 + dependency: transitive
  203 + description:
  204 + name: node_preamble
  205 + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
  206 + url: "https://pub.dev"
  207 + source: hosted
  208 + version: "2.0.2"
  209 + package_config:
  210 + dependency: transitive
  211 + description:
  212 + name: package_config
  213 + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
  214 + url: "https://pub.dev"
  215 + source: hosted
  216 + version: "2.1.0"
  217 + path:
  218 + dependency: "direct main"
  219 + description:
  220 + name: path
  221 + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
  222 + url: "https://pub.dev"
  223 + source: hosted
  224 + version: "1.9.0"
  225 + pool:
  226 + dependency: transitive
  227 + description:
  228 + name: pool
  229 + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
  230 + url: "https://pub.dev"
  231 + source: hosted
  232 + version: "1.5.1"
  233 + pub_semver:
  234 + dependency: transitive
  235 + description:
  236 + name: pub_semver
  237 + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
  238 + url: "https://pub.dev"
  239 + source: hosted
  240 + version: "2.1.4"
  241 + shelf:
  242 + dependency: transitive
  243 + description:
  244 + name: shelf
  245 + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
  246 + url: "https://pub.dev"
  247 + source: hosted
  248 + version: "1.4.1"
  249 + shelf_packages_handler:
  250 + dependency: transitive
  251 + description:
  252 + name: shelf_packages_handler
  253 + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
  254 + url: "https://pub.dev"
  255 + source: hosted
  256 + version: "3.0.2"
  257 + shelf_static:
  258 + dependency: transitive
  259 + description:
  260 + name: shelf_static
  261 + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
  262 + url: "https://pub.dev"
  263 + source: hosted
  264 + version: "1.1.2"
  265 + shelf_web_socket:
  266 + dependency: transitive
  267 + description:
  268 + name: shelf_web_socket
  269 + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
  270 + url: "https://pub.dev"
  271 + source: hosted
  272 + version: "1.0.4"
  273 + sherpa_onnx:
  274 + dependency: "direct main"
  275 + description:
  276 + name: sherpa_onnx
  277 + sha256: e45894f81e7c854ca96d678bcab5303036e884a7c90e9a6c4ec04c7b1ee215a8
  278 + url: "https://pub.dev"
  279 + source: hosted
  280 + version: "1.9.29"
  281 + sky_engine:
  282 + dependency: transitive
  283 + description: flutter
  284 + source: sdk
  285 + version: "0.0.99"
  286 + source_map_stack_trace:
  287 + dependency: transitive
  288 + description:
  289 + name: source_map_stack_trace
  290 + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
  291 + url: "https://pub.dev"
  292 + source: hosted
  293 + version: "2.1.1"
  294 + source_maps:
  295 + dependency: transitive
  296 + description:
  297 + name: source_maps
  298 + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
  299 + url: "https://pub.dev"
  300 + source: hosted
  301 + version: "0.10.12"
  302 + source_span:
  303 + dependency: transitive
  304 + description:
  305 + name: source_span
  306 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
  307 + url: "https://pub.dev"
  308 + source: hosted
  309 + version: "1.10.0"
  310 + stack_trace:
  311 + dependency: transitive
  312 + description:
  313 + name: stack_trace
  314 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
  315 + url: "https://pub.dev"
  316 + source: hosted
  317 + version: "1.11.1"
  318 + stream_channel:
  319 + dependency: transitive
  320 + description:
  321 + name: stream_channel
  322 + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
  323 + url: "https://pub.dev"
  324 + source: hosted
  325 + version: "2.1.2"
  326 + string_scanner:
  327 + dependency: transitive
  328 + description:
  329 + name: string_scanner
  330 + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
  331 + url: "https://pub.dev"
  332 + source: hosted
  333 + version: "1.2.0"
  334 + term_glyph:
  335 + dependency: transitive
  336 + description:
  337 + name: term_glyph
  338 + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
  339 + url: "https://pub.dev"
  340 + source: hosted
  341 + version: "1.2.1"
  342 + test:
  343 + dependency: "direct dev"
  344 + description:
  345 + name: test
  346 + sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
  347 + url: "https://pub.dev"
  348 + source: hosted
  349 + version: "1.25.2"
  350 + test_api:
  351 + dependency: transitive
  352 + description:
  353 + name: test_api
  354 + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
  355 + url: "https://pub.dev"
  356 + source: hosted
  357 + version: "0.7.0"
  358 + test_core:
  359 + dependency: transitive
  360 + description:
  361 + name: test_core
  362 + sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
  363 + url: "https://pub.dev"
  364 + source: hosted
  365 + version: "0.6.0"
  366 + typed_data:
  367 + dependency: transitive
  368 + description:
  369 + name: typed_data
  370 + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
  371 + url: "https://pub.dev"
  372 + source: hosted
  373 + version: "1.3.2"
  374 + vector_math:
  375 + dependency: transitive
  376 + description:
  377 + name: vector_math
  378 + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
  379 + url: "https://pub.dev"
  380 + source: hosted
  381 + version: "2.1.4"
  382 + vm_service:
  383 + dependency: transitive
  384 + description:
  385 + name: vm_service
  386 + sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
  387 + url: "https://pub.dev"
  388 + source: hosted
  389 + version: "14.2.4"
  390 + watcher:
  391 + dependency: transitive
  392 + description:
  393 + name: watcher
  394 + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
  395 + url: "https://pub.dev"
  396 + source: hosted
  397 + version: "1.1.0"
  398 + web:
  399 + dependency: transitive
  400 + description:
  401 + name: web
  402 + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
  403 + url: "https://pub.dev"
  404 + source: hosted
  405 + version: "0.5.1"
  406 + web_socket_channel:
  407 + dependency: transitive
  408 + description:
  409 + name: web_socket_channel
  410 + sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
  411 + url: "https://pub.dev"
  412 + source: hosted
  413 + version: "2.4.5"
  414 + webkit_inspection_protocol:
  415 + dependency: transitive
  416 + description:
  417 + name: webkit_inspection_protocol
  418 + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
  419 + url: "https://pub.dev"
  420 + source: hosted
  421 + version: "1.2.1"
  422 + yaml:
  423 + dependency: transitive
  424 + description:
  425 + name: yaml
  426 + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
  427 + url: "https://pub.dev"
  428 + source: hosted
  429 + version: "3.1.2"
  430 +sdks:
  431 + dart: ">=3.4.0 <4.0.0"
  432 + flutter: ">=3.3.0"
  1 +name: streaming_asr
  2 +
  3 +description: >
  4 + This example demonstrates how to use the Dart API for streaming speech recognition.
  5 +
  6 +version: 1.0.0
  7 +# repository: https://github.com/my_org/my_repo
  8 +
  9 +environment:
  10 + sdk: ^3.4.0
  11 +
  12 +# Add regular dependencies here.
  13 +dependencies:
  14 + sherpa_onnx: ^1.9.29
  15 + path: ^1.9.0
  16 + args: ^2.5.0
  17 +
  18 +dev_dependencies:
  19 + lints: ^3.0.0
  20 + test: ^1.24.0
  1 +#!/usr/bin/env bash
  2 +
  3 +set -ex
  4 +
  5 +dart pub get
  6 +
  7 +if [ ! -f ./sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms/tokens.txt ]; then
  8 + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms.tar.bz2
  9 + tar xvf sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms.tar.bz2
  10 + rm sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms.tar.bz2
  11 +fi
  12 +
  13 +dart run \
  14 + ./bin/zipformer-transducer.dart \
  15 + --encoder ./sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms/encoder.onnx \
  16 + --decoder ./sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms/decoder.onnx \
  17 + --joiner ./sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms/joiner.onnx \
  18 + --tokens ./sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms/tokens.txt \
  19 + --input-wav ./sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-80ms/test_wavs/0.wav
  1 +#!/usr/bin/env bash
  2 +
  3 +set -ex
  4 +
  5 +dart pub get
  6 +
  7 +if [ ! -f ./sherpa-onnx-streaming-paraformer-bilingual-zh-en/tokens.txt ]; then
  8 + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
  9 + tar xvf sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
  10 + rm sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
  11 +fi
  12 +
  13 +dart run \
  14 + ./bin/paraformer.dart \
  15 + --encoder ./sherpa-onnx-streaming-paraformer-bilingual-zh-en/encoder.int8.onnx \
  16 + --decoder ./sherpa-onnx-streaming-paraformer-bilingual-zh-en/decoder.int8.onnx \
  17 + --tokens ./sherpa-onnx-streaming-paraformer-bilingual-zh-en/tokens.txt \
  18 + --input-wav ./sherpa-onnx-streaming-paraformer-bilingual-zh-en/test_wavs/0.wav
  1 +#!/usr/bin/env bash
  2 +
  3 +set -ex
  4 +
  5 +dart pub get
  6 +
  7 +if [ ! -f ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/tokens.txt ]; then
  8 + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2
  9 + tar xvf sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2
  10 + rm sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2
  11 +fi
  12 +
  13 +dart run \
  14 + ./bin/zipformer-ctc-hlg.dart \
  15 + --model ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/ctc-epoch-30-avg-3-chunk-16-left-128.int8.onnx \
  16 + --hlg ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/HLG.fst \
  17 + --tokens ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/tokens.txt \
  18 + --input-wav ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/test_wavs/1.wav
  1 +#!/usr/bin/env bash
  2 +
  3 +set -ex
  4 +
  5 +dart pub get
  6 +
  7 +if [ ! -f ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/tokens.txt ]; then
  8 + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2
  9 + tar xvf sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2
  10 + rm sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2
  11 +fi
  12 +
  13 +dart run \
  14 + ./bin/zipformer-ctc.dart \
  15 + --model ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/ctc-epoch-30-avg-3-chunk-16-left-128.int8.onnx \
  16 + --tokens ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/tokens.txt \
  17 + --input-wav ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/test_wavs/1.wav
  1 +#!/usr/bin/env bash
  2 +
  3 +set -ex
  4 +
  5 +dart pub get
  6 +
  7 +if [ ! -f ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt ]; then
  8 + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
  9 + tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
  10 + rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
  11 +fi
  12 +
  13 +dart run \
  14 + ./bin/zipformer-transducer.dart \
  15 + --encoder ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.int8.onnx \
  16 + --decoder ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx \
  17 + --joiner ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.int8.onnx \
  18 + --tokens ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt \
  19 + --input-wav ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/test_wavs/0.wav
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:isolate'; 3 import 'dart:isolate';
3 import 'package:path/path.dart' as p; 4 import 'package:path/path.dart' as p;
  1 +// Copyright (c) 2024 Xiaomi Corporation
1 import 'dart:io'; 2 import 'dart:io';
2 import 'dart:typed_data'; 3 import 'dart:typed_data';
3 4
1 { 1 {
2 "dependencies": { 2 "dependencies": {
3 - "sherpa-onnx-node": "^1.0.27" 3 + "sherpa-onnx-node": "^1.9.29"
4 } 4 }
5 } 5 }
  1 +name: streaming_asr
  2 +
  3 +description: >
  4 + This example demonstrates how to use the Dart API for streaming speech recognition.
  5 +
  6 +version: 1.0.0
  7 +# repository: https://github.com/my_org/my_repo
  8 +
  9 +environment:
  10 + sdk: ^3.4.0
  11 +
  12 +# Add regular dependencies here.
  13 +dependencies:
  14 + sherpa_onnx:
  15 + path: ../../sherpa-onnx/flutter
  16 + path: ^1.9.0
  17 + args: ^2.5.0
  18 +
  19 +dev_dependencies:
  20 + lints: ^3.0.0
  21 + test: ^1.24.0