Committed by
GitHub
Dart API for adding punctuations to text (#1182)
正在显示
30 个修改的文件
包含
327 行增加
和
22 行删除
| @@ -4,6 +4,11 @@ set -ex | @@ -4,6 +4,11 @@ set -ex | ||
| 4 | 4 | ||
| 5 | cd dart-api-examples | 5 | cd dart-api-examples |
| 6 | 6 | ||
| 7 | +pushd add-punctuations | ||
| 8 | +echo '----------CT Transformer----------' | ||
| 9 | +./run-ct-transformer.sh | ||
| 10 | +popd | ||
| 11 | + | ||
| 7 | pushd audio-tagging | 12 | pushd audio-tagging |
| 8 | echo '----------zipformer----------' | 13 | echo '----------zipformer----------' |
| 9 | ./run-zipformer.sh | 14 | ./run-zipformer.sh |
| @@ -111,6 +111,7 @@ jobs: | @@ -111,6 +111,7 @@ jobs: | ||
| 111 | cp scripts/dart/kws-pubspec.yaml dart-api-examples/keyword-spotter/pubspec.yaml | 111 | cp scripts/dart/kws-pubspec.yaml dart-api-examples/keyword-spotter/pubspec.yaml |
| 112 | cp scripts/dart/vad-non-streaming-asr-pubspec.yaml dart-api-examples/vad-with-non-streaming-asr/pubspec.yaml | 112 | cp scripts/dart/vad-non-streaming-asr-pubspec.yaml dart-api-examples/vad-with-non-streaming-asr/pubspec.yaml |
| 113 | cp scripts/dart/audio-tagging-pubspec.yaml dart-api-examples/audio-tagging/pubspec.yaml | 113 | cp scripts/dart/audio-tagging-pubspec.yaml dart-api-examples/audio-tagging/pubspec.yaml |
| 114 | + cp scripts/dart/add-punctuations-pubspec.yaml dart-api-examples/add-punctuations/pubspec.yaml | ||
| 114 | 115 | ||
| 115 | cp scripts/dart/sherpa-onnx-pubspec.yaml flutter/sherpa_onnx/pubspec.yaml | 116 | cp scripts/dart/sherpa-onnx-pubspec.yaml flutter/sherpa_onnx/pubspec.yaml |
| 116 | 117 |
| @@ -11,7 +11,7 @@ project(sherpa-onnx) | @@ -11,7 +11,7 @@ project(sherpa-onnx) | ||
| 11 | # ./nodejs-addon-examples | 11 | # ./nodejs-addon-examples |
| 12 | # ./dart-api-examples/ | 12 | # ./dart-api-examples/ |
| 13 | # ./CHANGELOG.md | 13 | # ./CHANGELOG.md |
| 14 | -set(SHERPA_ONNX_VERSION "1.10.19") | 14 | +set(SHERPA_ONNX_VERSION "1.10.20") |
| 15 | 15 | ||
| 16 | # Disable warning about | 16 | # Disable warning about |
| 17 | # | 17 | # |
| @@ -16,6 +16,7 @@ https://pub.dev/packages/sherpa_onnx | @@ -16,6 +16,7 @@ https://pub.dev/packages/sherpa_onnx | ||
| 16 | | [./vad](./vad)| Example for voice activity detection| | 16 | | [./vad](./vad)| Example for voice activity detection| |
| 17 | | [./vad-with-non-streaming-asr](./vad-with-non-streaming-asr)| Example for voice activity detection with non-streaming speech recognition. You can use it to generate subtitles.| | 17 | | [./vad-with-non-streaming-asr](./vad-with-non-streaming-asr)| Example for voice activity detection with non-streaming speech recognition. You can use it to generate subtitles.| |
| 18 | | [./audio-tagging](./audio-tagging)| Example for audio tagging.| | 18 | | [./audio-tagging](./audio-tagging)| Example for audio tagging.| |
| 19 | +| [./add-punctuations](./add-punctuations)| Example for adding punctuations to text.| | ||
| 19 | 20 | ||
| 20 | ## How to create an example in this folder | 21 | ## How to create an example in this folder |
| 21 | 22 |
dart-api-examples/add-punctuations/README.md
0 → 100644
| 1 | +# Introduction | ||
| 2 | + | ||
| 3 | +This example shows how to use the Dart API from sherpa-onnx to add punctuations to text. | ||
| 4 | + | ||
| 5 | +| File | Description| | ||
| 6 | +|------|------------| | ||
| 7 | +|[./bin/punctuations.dart](./bin/punctuations.dart)| Use a [CT Transformer model](https://modelscope.cn/models/iic/punc_ct-transformer_zh-cn-common-vocab272727-pytorch/summary) to add punctuations to text. See [./run-ct-transformer.sh](./run-ct-transformer.sh)| | ||
| 8 | + |
| 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 | +../../vad/bin/init.dart |
| 1 | +// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | +import 'dart:io'; | ||
| 3 | + | ||
| 4 | +import 'package:args/args.dart'; | ||
| 5 | +import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 6 | +import './init.dart'; | ||
| 7 | + | ||
| 8 | +void main(List<String> arguments) async { | ||
| 9 | + await initSherpaOnnx(); | ||
| 10 | + | ||
| 11 | + final parser = ArgParser()..addOption('model', help: 'Path to model.onnx'); | ||
| 12 | + | ||
| 13 | + final res = parser.parse(arguments); | ||
| 14 | + if (res['model'] == null) { | ||
| 15 | + print(parser.usage); | ||
| 16 | + exit(1); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + final modelFile = res['model'] as String; | ||
| 20 | + final modelConfig = sherpa_onnx.OfflinePunctuationModelConfig( | ||
| 21 | + ctTransformer: modelFile, | ||
| 22 | + numThreads: 1, | ||
| 23 | + provider: 'cpu', | ||
| 24 | + debug: false, | ||
| 25 | + ); | ||
| 26 | + | ||
| 27 | + final config = sherpa_onnx.OfflinePunctuationConfig(model: modelConfig); | ||
| 28 | + | ||
| 29 | + final punct = sherpa_onnx.OfflinePunctuation(config: config); | ||
| 30 | + | ||
| 31 | + final texts = [ | ||
| 32 | + '这是一个测试你好吗How are you我很好thank you are you ok谢谢你', | ||
| 33 | + '我们都是木头人不会说话不会动', | ||
| 34 | + 'The African blogosphere is rapidly expanding bringing more voices online in the form of commentaries opinions analyses rants and poetry', | ||
| 35 | + ]; | ||
| 36 | + | ||
| 37 | + for (final t in texts) { | ||
| 38 | + final textWithPunct = punct.addPunct(t); | ||
| 39 | + print('----------'); | ||
| 40 | + print('Before: $t'); | ||
| 41 | + print('After: $textWithPunct'); | ||
| 42 | + } | ||
| 43 | + print('----------'); | ||
| 44 | + | ||
| 45 | + punct.free(); | ||
| 46 | +} |
| 1 | +name: add_punctuations | ||
| 2 | + | ||
| 3 | +description: > | ||
| 4 | + This example demonstrates how to use the Dart API to add punctuations to text. | ||
| 5 | + | ||
| 6 | +version: 1.0.0 | ||
| 7 | + | ||
| 8 | +environment: | ||
| 9 | + sdk: ^3.4.0 | ||
| 10 | + | ||
| 11 | +dependencies: | ||
| 12 | + sherpa_onnx: ^1.10.20 | ||
| 13 | + path: ^1.9.0 | ||
| 14 | + args: ^2.5.0 | ||
| 15 | + | ||
| 16 | +dev_dependencies: | ||
| 17 | + lints: ^3.0.0 |
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +set -ex | ||
| 4 | + | ||
| 5 | +dart pub get | ||
| 6 | + | ||
| 7 | +if [[ ! -f ./sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12/model.onnx ]]; then | ||
| 8 | + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2 | ||
| 9 | + tar xvf sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2 | ||
| 10 | + rm sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2 | ||
| 11 | +fi | ||
| 12 | + | ||
| 13 | +dart run \ | ||
| 14 | + ./bin/punctuations.dart \ | ||
| 15 | + --model ./sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12/model.onnx |
| @@ -9,7 +9,7 @@ environment: | @@ -9,7 +9,7 @@ environment: | ||
| 9 | sdk: ^3.4.0 | 9 | sdk: ^3.4.0 |
| 10 | 10 | ||
| 11 | dependencies: | 11 | dependencies: |
| 12 | - sherpa_onnx: ^1.10.19 | 12 | + sherpa_onnx: ^1.10.20 |
| 13 | # sherpa_onnx: | 13 | # sherpa_onnx: |
| 14 | # path: ../../flutter/sherpa_onnx | 14 | # path: ../../flutter/sherpa_onnx |
| 15 | path: ^1.9.0 | 15 | path: ^1.9.0 |
| @@ -5,7 +5,7 @@ description: > | @@ -5,7 +5,7 @@ description: > | ||
| 5 | 5 | ||
| 6 | publish_to: 'none' | 6 | publish_to: 'none' |
| 7 | 7 | ||
| 8 | -version: 1.10.19 | 8 | +version: 1.10.20 |
| 9 | 9 | ||
| 10 | topics: | 10 | topics: |
| 11 | - speech-recognition | 11 | - speech-recognition |
| @@ -30,7 +30,7 @@ dependencies: | @@ -30,7 +30,7 @@ dependencies: | ||
| 30 | record: ^5.1.0 | 30 | record: ^5.1.0 |
| 31 | url_launcher: ^6.2.6 | 31 | url_launcher: ^6.2.6 |
| 32 | 32 | ||
| 33 | - sherpa_onnx: ^1.10.19 | 33 | + sherpa_onnx: ^1.10.20 |
| 34 | # sherpa_onnx: | 34 | # sherpa_onnx: |
| 35 | # path: ../../flutter/sherpa_onnx | 35 | # path: ../../flutter/sherpa_onnx |
| 36 | 36 |
| @@ -5,7 +5,7 @@ description: > | @@ -5,7 +5,7 @@ description: > | ||
| 5 | 5 | ||
| 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev | 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev |
| 7 | 7 | ||
| 8 | -version: 1.10.19 | 8 | +version: 1.10.20 |
| 9 | 9 | ||
| 10 | environment: | 10 | environment: |
| 11 | sdk: '>=3.4.0 <4.0.0' | 11 | sdk: '>=3.4.0 <4.0.0' |
| @@ -17,7 +17,7 @@ dependencies: | @@ -17,7 +17,7 @@ dependencies: | ||
| 17 | cupertino_icons: ^1.0.6 | 17 | cupertino_icons: ^1.0.6 |
| 18 | path_provider: ^2.1.3 | 18 | path_provider: ^2.1.3 |
| 19 | path: ^1.9.0 | 19 | path: ^1.9.0 |
| 20 | - sherpa_onnx: ^1.10.19 | 20 | + sherpa_onnx: ^1.10.20 |
| 21 | url_launcher: ^6.2.6 | 21 | url_launcher: ^6.2.6 |
| 22 | audioplayers: ^5.0.0 | 22 | audioplayers: ^5.0.0 |
| 23 | 23 |
| @@ -9,6 +9,7 @@ export 'src/offline_recognizer.dart'; | @@ -9,6 +9,7 @@ export 'src/offline_recognizer.dart'; | ||
| 9 | export 'src/offline_stream.dart'; | 9 | export 'src/offline_stream.dart'; |
| 10 | export 'src/online_recognizer.dart'; | 10 | export 'src/online_recognizer.dart'; |
| 11 | export 'src/online_stream.dart'; | 11 | export 'src/online_stream.dart'; |
| 12 | +export 'src/punctuation.dart'; | ||
| 12 | export 'src/speaker_identification.dart'; | 13 | export 'src/speaker_identification.dart'; |
| 13 | export 'src/tts.dart'; | 14 | export 'src/tts.dart'; |
| 14 | export 'src/vad.dart'; | 15 | export 'src/vad.dart'; |
flutter/sherpa_onnx/lib/src/punctuation.dart
0 → 100644
| 1 | +// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | +import 'dart:ffi'; | ||
| 3 | +import 'package:ffi/ffi.dart'; | ||
| 4 | + | ||
| 5 | +import './sherpa_onnx_bindings.dart'; | ||
| 6 | + | ||
| 7 | +class OfflinePunctuationModelConfig { | ||
| 8 | + OfflinePunctuationModelConfig( | ||
| 9 | + {required this.ctTransformer, | ||
| 10 | + this.numThreads = 1, | ||
| 11 | + this.provider = 'cpu', | ||
| 12 | + this.debug = true}); | ||
| 13 | + | ||
| 14 | + @override | ||
| 15 | + String toString() { | ||
| 16 | + return 'OfflinePunctuationModelConfig(ctTransformer: $ctTransformer, numThreads: $numThreads, provider: $provider, debug: $debug)'; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + final String ctTransformer; | ||
| 20 | + final int numThreads; | ||
| 21 | + final String provider; | ||
| 22 | + final bool debug; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +class OfflinePunctuationConfig { | ||
| 26 | + OfflinePunctuationConfig({ | ||
| 27 | + required this.model, | ||
| 28 | + }); | ||
| 29 | + | ||
| 30 | + @override | ||
| 31 | + String toString() { | ||
| 32 | + return 'OfflinePunctuationConfig(model: $model)'; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + final OfflinePunctuationModelConfig model; | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +class OfflinePunctuation { | ||
| 39 | + OfflinePunctuation._({required this.ptr, required this.config}); | ||
| 40 | + | ||
| 41 | + // The user has to invoke OfflinePunctuation.free() to avoid memory leak. | ||
| 42 | + factory OfflinePunctuation({required OfflinePunctuationConfig config}) { | ||
| 43 | + final c = calloc<SherpaOnnxOfflinePunctuationConfig>(); | ||
| 44 | + | ||
| 45 | + final ctTransformerPtr = config.model.ctTransformer.toNativeUtf8(); | ||
| 46 | + c.ref.model.ctTransformer = ctTransformerPtr; | ||
| 47 | + c.ref.model.numThreads = config.model.numThreads; | ||
| 48 | + c.ref.model.debug = config.model.debug ? 1 : 0; | ||
| 49 | + | ||
| 50 | + final providerPtr = config.model.provider.toNativeUtf8(); | ||
| 51 | + c.ref.model.provider = providerPtr; | ||
| 52 | + | ||
| 53 | + final ptr = | ||
| 54 | + SherpaOnnxBindings.sherpaOnnxCreateOfflinePunctuation?.call(c) ?? | ||
| 55 | + nullptr; | ||
| 56 | + | ||
| 57 | + calloc.free(providerPtr); | ||
| 58 | + calloc.free(ctTransformerPtr); | ||
| 59 | + calloc.free(c); | ||
| 60 | + | ||
| 61 | + return OfflinePunctuation._(ptr: ptr, config: config); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + void free() { | ||
| 65 | + SherpaOnnxBindings.sherpaOnnxDestroyOfflinePunctuation?.call(ptr); | ||
| 66 | + ptr = nullptr; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + String addPunct(String text) { | ||
| 70 | + final textPtr = text.toNativeUtf8(); | ||
| 71 | + | ||
| 72 | + final p = SherpaOnnxBindings.sherpaOfflinePunctuationAddPunct | ||
| 73 | + ?.call(ptr, textPtr) ?? | ||
| 74 | + nullptr; | ||
| 75 | + | ||
| 76 | + calloc.free(textPtr); | ||
| 77 | + | ||
| 78 | + if (p == nullptr) { | ||
| 79 | + return ''; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + final ans = p.toDartString(); | ||
| 83 | + | ||
| 84 | + SherpaOnnxBindings.sherpaOfflinePunctuationFreeText?.call(p); | ||
| 85 | + | ||
| 86 | + return ans; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + Pointer<SherpaOnnxOfflinePunctuation> ptr; | ||
| 90 | + final OfflinePunctuationConfig config; | ||
| 91 | +} |
| @@ -2,6 +2,22 @@ | @@ -2,6 +2,22 @@ | ||
| 2 | import 'dart:ffi'; | 2 | import 'dart:ffi'; |
| 3 | import 'package:ffi/ffi.dart'; | 3 | import 'package:ffi/ffi.dart'; |
| 4 | 4 | ||
| 5 | +final class SherpaOnnxOfflinePunctuationModelConfig extends Struct { | ||
| 6 | + external Pointer<Utf8> ctTransformer; | ||
| 7 | + | ||
| 8 | + @Int32() | ||
| 9 | + external int numThreads; | ||
| 10 | + | ||
| 11 | + @Int32() | ||
| 12 | + external int debug; | ||
| 13 | + | ||
| 14 | + external Pointer<Utf8> provider; | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +final class SherpaOnnxOfflinePunctuationConfig extends Struct { | ||
| 18 | + external SherpaOnnxOfflinePunctuationModelConfig model; | ||
| 19 | +} | ||
| 20 | + | ||
| 5 | final class SherpaOnnxOfflineZipformerAudioTaggingModelConfig extends Struct { | 21 | final class SherpaOnnxOfflineZipformerAudioTaggingModelConfig extends Struct { |
| 6 | external Pointer<Utf8> model; | 22 | external Pointer<Utf8> model; |
| 7 | } | 23 | } |
| @@ -338,6 +354,8 @@ final class SherpaOnnxKeywordSpotterConfig extends Struct { | @@ -338,6 +354,8 @@ final class SherpaOnnxKeywordSpotterConfig extends Struct { | ||
| 338 | external Pointer<Utf8> keywordsFile; | 354 | external Pointer<Utf8> keywordsFile; |
| 339 | } | 355 | } |
| 340 | 356 | ||
| 357 | +final class SherpaOnnxOfflinePunctuation extends Opaque {} | ||
| 358 | + | ||
| 341 | final class SherpaOnnxAudioTagging extends Opaque {} | 359 | final class SherpaOnnxAudioTagging extends Opaque {} |
| 342 | 360 | ||
| 343 | final class SherpaOnnxKeywordSpotter extends Opaque {} | 361 | final class SherpaOnnxKeywordSpotter extends Opaque {} |
| @@ -360,6 +378,29 @@ final class SherpaOnnxSpeakerEmbeddingExtractor extends Opaque {} | @@ -360,6 +378,29 @@ final class SherpaOnnxSpeakerEmbeddingExtractor extends Opaque {} | ||
| 360 | 378 | ||
| 361 | final class SherpaOnnxSpeakerEmbeddingManager extends Opaque {} | 379 | final class SherpaOnnxSpeakerEmbeddingManager extends Opaque {} |
| 362 | 380 | ||
| 381 | +typedef SherpaOnnxCreateOfflinePunctuationNative | ||
| 382 | + = Pointer<SherpaOnnxOfflinePunctuation> Function( | ||
| 383 | + Pointer<SherpaOnnxOfflinePunctuationConfig>); | ||
| 384 | + | ||
| 385 | +typedef SherpaOnnxCreateOfflinePunctuation | ||
| 386 | + = SherpaOnnxCreateOfflinePunctuationNative; | ||
| 387 | + | ||
| 388 | +typedef SherpaOnnxDestroyOfflinePunctuationNative = Void Function( | ||
| 389 | + Pointer<SherpaOnnxOfflinePunctuation>); | ||
| 390 | + | ||
| 391 | +typedef SherpaOnnxDestroyOfflinePunctuation = void Function( | ||
| 392 | + Pointer<SherpaOnnxOfflinePunctuation>); | ||
| 393 | + | ||
| 394 | +typedef SherpaOfflinePunctuationAddPunctNative = Pointer<Utf8> Function( | ||
| 395 | + Pointer<SherpaOnnxOfflinePunctuation>, Pointer<Utf8>); | ||
| 396 | + | ||
| 397 | +typedef SherpaOfflinePunctuationAddPunct | ||
| 398 | + = SherpaOfflinePunctuationAddPunctNative; | ||
| 399 | + | ||
| 400 | +typedef SherpaOfflinePunctuationFreeTextNative = Void Function(Pointer<Utf8>); | ||
| 401 | + | ||
| 402 | +typedef SherpaOfflinePunctuationFreeText = void Function(Pointer<Utf8>); | ||
| 403 | + | ||
| 363 | typedef SherpaOnnxCreateAudioTaggingNative = Pointer<SherpaOnnxAudioTagging> | 404 | typedef SherpaOnnxCreateAudioTaggingNative = Pointer<SherpaOnnxAudioTagging> |
| 364 | Function(Pointer<SherpaOnnxAudioTaggingConfig>); | 405 | Function(Pointer<SherpaOnnxAudioTaggingConfig>); |
| 365 | 406 | ||
| @@ -875,6 +916,12 @@ typedef SherpaOnnxFreeWaveNative = Void Function(Pointer<SherpaOnnxWave>); | @@ -875,6 +916,12 @@ typedef SherpaOnnxFreeWaveNative = Void Function(Pointer<SherpaOnnxWave>); | ||
| 875 | typedef SherpaOnnxFreeWave = void Function(Pointer<SherpaOnnxWave>); | 916 | typedef SherpaOnnxFreeWave = void Function(Pointer<SherpaOnnxWave>); |
| 876 | 917 | ||
| 877 | class SherpaOnnxBindings { | 918 | class SherpaOnnxBindings { |
| 919 | + static SherpaOnnxCreateOfflinePunctuation? sherpaOnnxCreateOfflinePunctuation; | ||
| 920 | + static SherpaOnnxDestroyOfflinePunctuation? | ||
| 921 | + sherpaOnnxDestroyOfflinePunctuation; | ||
| 922 | + static SherpaOfflinePunctuationAddPunct? sherpaOfflinePunctuationAddPunct; | ||
| 923 | + static SherpaOfflinePunctuationFreeText? sherpaOfflinePunctuationFreeText; | ||
| 924 | + | ||
| 878 | static SherpaOnnxCreateAudioTagging? sherpaOnnxCreateAudioTagging; | 925 | static SherpaOnnxCreateAudioTagging? sherpaOnnxCreateAudioTagging; |
| 879 | static SherpaOnnxDestroyAudioTagging? sherpaOnnxDestroyAudioTagging; | 926 | static SherpaOnnxDestroyAudioTagging? sherpaOnnxDestroyAudioTagging; |
| 880 | static SherpaOnnxAudioTaggingCreateOfflineStream? | 927 | static SherpaOnnxAudioTaggingCreateOfflineStream? |
| @@ -1036,6 +1083,26 @@ class SherpaOnnxBindings { | @@ -1036,6 +1083,26 @@ class SherpaOnnxBindings { | ||
| 1036 | static SherpaOnnxFreeWave? freeWave; | 1083 | static SherpaOnnxFreeWave? freeWave; |
| 1037 | 1084 | ||
| 1038 | static void init(DynamicLibrary dynamicLibrary) { | 1085 | static void init(DynamicLibrary dynamicLibrary) { |
| 1086 | + sherpaOnnxCreateOfflinePunctuation ??= dynamicLibrary | ||
| 1087 | + .lookup<NativeFunction<SherpaOnnxCreateOfflinePunctuationNative>>( | ||
| 1088 | + 'SherpaOnnxCreateOfflinePunctuation') | ||
| 1089 | + .asFunction(); | ||
| 1090 | + | ||
| 1091 | + sherpaOnnxDestroyOfflinePunctuation ??= dynamicLibrary | ||
| 1092 | + .lookup<NativeFunction<SherpaOnnxDestroyOfflinePunctuationNative>>( | ||
| 1093 | + 'SherpaOnnxDestroyOfflinePunctuation') | ||
| 1094 | + .asFunction(); | ||
| 1095 | + | ||
| 1096 | + sherpaOfflinePunctuationAddPunct ??= dynamicLibrary | ||
| 1097 | + .lookup<NativeFunction<SherpaOfflinePunctuationAddPunctNative>>( | ||
| 1098 | + 'SherpaOfflinePunctuationAddPunct') | ||
| 1099 | + .asFunction(); | ||
| 1100 | + | ||
| 1101 | + sherpaOfflinePunctuationFreeText ??= dynamicLibrary | ||
| 1102 | + .lookup<NativeFunction<SherpaOfflinePunctuationFreeTextNative>>( | ||
| 1103 | + 'SherpaOfflinePunctuationFreeText') | ||
| 1104 | + .asFunction(); | ||
| 1105 | + | ||
| 1039 | sherpaOnnxCreateAudioTagging ??= dynamicLibrary | 1106 | sherpaOnnxCreateAudioTagging ??= dynamicLibrary |
| 1040 | .lookup<NativeFunction<SherpaOnnxCreateAudioTaggingNative>>( | 1107 | .lookup<NativeFunction<SherpaOnnxCreateAudioTaggingNative>>( |
| 1041 | 'SherpaOnnxCreateAudioTagging') | 1108 | 'SherpaOnnxCreateAudioTagging') |
| @@ -17,7 +17,7 @@ topics: | @@ -17,7 +17,7 @@ topics: | ||
| 17 | - voice-activity-detection | 17 | - voice-activity-detection |
| 18 | 18 | ||
| 19 | # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec | 19 | # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec |
| 20 | -version: 1.10.19 | 20 | +version: 1.10.20 |
| 21 | 21 | ||
| 22 | homepage: https://github.com/k2-fsa/sherpa-onnx | 22 | homepage: https://github.com/k2-fsa/sherpa-onnx |
| 23 | 23 | ||
| @@ -30,23 +30,23 @@ dependencies: | @@ -30,23 +30,23 @@ dependencies: | ||
| 30 | flutter: | 30 | flutter: |
| 31 | sdk: flutter | 31 | sdk: flutter |
| 32 | 32 | ||
| 33 | - sherpa_onnx_android: ^1.10.19 | 33 | + sherpa_onnx_android: ^1.10.20 |
| 34 | # sherpa_onnx_android: | 34 | # sherpa_onnx_android: |
| 35 | # path: ../sherpa_onnx_android | 35 | # path: ../sherpa_onnx_android |
| 36 | 36 | ||
| 37 | - sherpa_onnx_macos: ^1.10.19 | 37 | + sherpa_onnx_macos: ^1.10.20 |
| 38 | # sherpa_onnx_macos: | 38 | # sherpa_onnx_macos: |
| 39 | # path: ../sherpa_onnx_macos | 39 | # path: ../sherpa_onnx_macos |
| 40 | 40 | ||
| 41 | - sherpa_onnx_linux: ^1.10.19 | 41 | + sherpa_onnx_linux: ^1.10.20 |
| 42 | # sherpa_onnx_linux: | 42 | # sherpa_onnx_linux: |
| 43 | # path: ../sherpa_onnx_linux | 43 | # path: ../sherpa_onnx_linux |
| 44 | # | 44 | # |
| 45 | - sherpa_onnx_windows: ^1.10.19 | 45 | + sherpa_onnx_windows: ^1.10.20 |
| 46 | # sherpa_onnx_windows: | 46 | # sherpa_onnx_windows: |
| 47 | # path: ../sherpa_onnx_windows | 47 | # path: ../sherpa_onnx_windows |
| 48 | 48 | ||
| 49 | - sherpa_onnx_ios: ^1.10.19 | 49 | + sherpa_onnx_ios: ^1.10.20 |
| 50 | # sherpa_onnx_ios: | 50 | # sherpa_onnx_ios: |
| 51 | # path: ../sherpa_onnx_ios | 51 | # path: ../sherpa_onnx_ios |
| 52 | 52 |
| @@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
| 7 | # https://groups.google.com/g/dart-ffi/c/nUATMBy7r0c | 7 | # https://groups.google.com/g/dart-ffi/c/nUATMBy7r0c |
| 8 | Pod::Spec.new do |s| | 8 | Pod::Spec.new do |s| |
| 9 | s.name = 'sherpa_onnx_ios' | 9 | s.name = 'sherpa_onnx_ios' |
| 10 | - s.version = '1.10.19' | 10 | + s.version = '1.10.20' |
| 11 | s.summary = 'A new Flutter FFI plugin project.' | 11 | s.summary = 'A new Flutter FFI plugin project.' |
| 12 | s.description = <<-DESC | 12 | s.description = <<-DESC |
| 13 | A new Flutter FFI plugin project. | 13 | A new Flutter FFI plugin project. |
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | # | 4 | # |
| 5 | Pod::Spec.new do |s| | 5 | Pod::Spec.new do |s| |
| 6 | s.name = 'sherpa_onnx_macos' | 6 | s.name = 'sherpa_onnx_macos' |
| 7 | - s.version = '1.10.19' | 7 | + s.version = '1.10.20' |
| 8 | s.summary = 'sherpa-onnx Flutter FFI plugin project.' | 8 | s.summary = 'sherpa-onnx Flutter FFI plugin project.' |
| 9 | s.description = <<-DESC | 9 | s.description = <<-DESC |
| 10 | sherpa-onnx Flutter FFI plugin project. | 10 | sherpa-onnx Flutter FFI plugin project. |
scripts/dart/add-punctuations-pubspec.yaml
0 → 100644
| 1 | +name: add_punctuations | ||
| 2 | + | ||
| 3 | +description: > | ||
| 4 | + This example demonstrates how to use the Dart API to add punctuations to text. | ||
| 5 | + | ||
| 6 | +version: 1.0.0 | ||
| 7 | + | ||
| 8 | +environment: | ||
| 9 | + sdk: ^3.4.0 | ||
| 10 | + | ||
| 11 | +dependencies: | ||
| 12 | + sherpa_onnx: | ||
| 13 | + path: ../../flutter/sherpa_onnx | ||
| 14 | + path: ^1.9.0 | ||
| 15 | + args: ^2.5.0 | ||
| 16 | + | ||
| 17 | +dev_dependencies: | ||
| 18 | + lints: ^3.0.0 |
| @@ -17,7 +17,7 @@ topics: | @@ -17,7 +17,7 @@ topics: | ||
| 17 | - voice-activity-detection | 17 | - voice-activity-detection |
| 18 | 18 | ||
| 19 | # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx.podspec | 19 | # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx.podspec |
| 20 | -version: 1.10.19 | 20 | +version: 1.10.20 |
| 21 | 21 | ||
| 22 | homepage: https://github.com/k2-fsa/sherpa-onnx | 22 | homepage: https://github.com/k2-fsa/sherpa-onnx |
| 23 | 23 |
-
请 注册 或 登录 后发表评论