Refactor C API to prefix each API with SherpaOnnx. (#1171)

This commit is contained in:
Fangjun Kuang
2024-07-26 18:47:02 +08:00
committed by GitHub
parent 994c3e7c96
commit 4e6aeff07e
47 changed files with 667 additions and 618 deletions

View File

@@ -461,26 +461,30 @@ typedef DestroyOfflineStreamResultJsonNative = Void Function(Pointer<Utf8>);
typedef DestroyOfflineStreamResultJson = void Function(Pointer<Utf8>);
typedef CreateOnlineRecognizerNative = Pointer<SherpaOnnxOnlineRecognizer>
Function(Pointer<SherpaOnnxOnlineRecognizerConfig>);
typedef SherpaOnnxCreateOnlineRecognizerNative
= Pointer<SherpaOnnxOnlineRecognizer> Function(
Pointer<SherpaOnnxOnlineRecognizerConfig>);
typedef CreateOnlineRecognizer = CreateOnlineRecognizerNative;
typedef SherpaOnnxCreateOnlineRecognizer
= SherpaOnnxCreateOnlineRecognizerNative;
typedef DestroyOnlineRecognizerNative = Void Function(
typedef SherpaOnnxDestroyOnlineRecognizerNative = Void Function(
Pointer<SherpaOnnxOnlineRecognizer>);
typedef DestroyOnlineRecognizer = void Function(
typedef SherpaOnnxDestroyOnlineRecognizer = void Function(
Pointer<SherpaOnnxOnlineRecognizer>);
typedef CreateOnlineStreamNative = Pointer<SherpaOnnxOnlineStream> Function(
Pointer<SherpaOnnxOnlineRecognizer>);
typedef SherpaOnnxCreateOnlineStreamNative = Pointer<SherpaOnnxOnlineStream>
Function(Pointer<SherpaOnnxOnlineRecognizer>);
typedef CreateOnlineStream = CreateOnlineStreamNative;
typedef SherpaOnnxCreateOnlineStream = SherpaOnnxCreateOnlineStreamNative;
typedef CreateOnlineStreamWithHotwordsNative = Pointer<SherpaOnnxOnlineStream>
Function(Pointer<SherpaOnnxOnlineRecognizer>, Pointer<Utf8>);
typedef SherpaOnnxCreateOnlineStreamWithHotwordsNative
= Pointer<SherpaOnnxOnlineStream> Function(
Pointer<SherpaOnnxOnlineRecognizer>, Pointer<Utf8>);
typedef CreateOnlineStreamWithHotwords = CreateOnlineStreamWithHotwordsNative;
typedef SherpaOnnxCreateOnlineStreamWithHotwords
= SherpaOnnxCreateOnlineStreamWithHotwordsNative;
typedef IsOnlineStreamReadyNative = Int32 Function(
Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>);
@@ -488,10 +492,10 @@ typedef IsOnlineStreamReadyNative = Int32 Function(
typedef IsOnlineStreamReady = int Function(
Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>);
typedef DecodeOnlineStreamNative = Void Function(
typedef SherpaOnnxDecodeOnlineStreamNative = Void Function(
Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>);
typedef DecodeOnlineStream = void Function(
typedef SherpaOnnxDecodeOnlineStream = void Function(
Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>);
typedef GetOnlineStreamResultAsJsonNative = Pointer<Utf8> Function(
@@ -745,10 +749,11 @@ typedef SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative
typedef SherpaOnnxSpeakerEmbeddingExtractorCreateStream
= SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative;
typedef DestroyOnlineStreamNative = Void Function(
typedef SherpaOnnxDestroyOnlineStreamNative = Void Function(
Pointer<SherpaOnnxOnlineStream>);
typedef DestroyOnlineStream = void Function(Pointer<SherpaOnnxOnlineStream>);
typedef SherpaOnnxDestroyOnlineStream = void Function(
Pointer<SherpaOnnxOnlineStream>);
typedef OnlineStreamAcceptWaveformNative = Void Function(
Pointer<SherpaOnnxOnlineStream>, Int32, Pointer<Float>, Int32);
@@ -827,17 +832,18 @@ class SherpaOnnxBindings {
static GetOfflineStreamResultAsJson? getOfflineStreamResultAsJson;
static DestroyOfflineStreamResultJson? destroyOfflineStreamResultJson;
static CreateOnlineRecognizer? createOnlineRecognizer;
static SherpaOnnxCreateOnlineRecognizer? createOnlineRecognizer;
static DestroyOnlineRecognizer? destroyOnlineRecognizer;
static SherpaOnnxDestroyOnlineRecognizer? destroyOnlineRecognizer;
static CreateOnlineStream? createOnlineStream;
static SherpaOnnxCreateOnlineStream? createOnlineStream;
static CreateOnlineStreamWithHotwords? createOnlineStreamWithHotwords;
static SherpaOnnxCreateOnlineStreamWithHotwords?
createOnlineStreamWithHotwords;
static IsOnlineStreamReady? isOnlineStreamReady;
static DecodeOnlineStream? decodeOnlineStream;
static SherpaOnnxDecodeOnlineStream? decodeOnlineStream;
static GetOnlineStreamResultAsJson? getOnlineStreamResultAsJson;
@@ -905,7 +911,7 @@ class SherpaOnnxBindings {
static SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding?
speakerEmbeddingExtractorDestroyEmbedding;
static DestroyOnlineStream? destroyOnlineStream;
static SherpaOnnxDestroyOnlineStream? destroyOnlineStream;
static OnlineStreamAcceptWaveform? onlineStreamAcceptWaveform;
@@ -954,42 +960,42 @@ class SherpaOnnxBindings {
static void init(DynamicLibrary dynamicLibrary) {
createKeywordSpotter ??= dynamicLibrary
.lookup<NativeFunction<CreateKeywordSpotterNative>>(
'CreateKeywordSpotter')
'SherpaOnnxCreateKeywordSpotter')
.asFunction();
destroyKeywordSpotter ??= dynamicLibrary
.lookup<NativeFunction<DestroyKeywordSpotterNative>>(
'DestroyKeywordSpotter')
'SherpaOnnxDestroyKeywordSpotter')
.asFunction();
createKeywordStream ??= dynamicLibrary
.lookup<NativeFunction<CreateKeywordStreamNative>>(
'CreateKeywordStream')
'SherpaOnnxCreateKeywordStream')
.asFunction();
createKeywordStreamWithKeywords ??= dynamicLibrary
.lookup<NativeFunction<CreateKeywordStreamWithKeywordsNative>>(
'CreateKeywordStreamWithKeywords')
'SherpaOnnxCreateKeywordStreamWithKeywords')
.asFunction();
isKeywordStreamReady ??= dynamicLibrary
.lookup<NativeFunction<IsKeywordStreamReadyNative>>(
'IsKeywordStreamReady')
'SherpaOnnxIsKeywordStreamReady')
.asFunction();
decodeKeywordStream ??= dynamicLibrary
.lookup<NativeFunction<DecodeKeywordStreamNative>>(
'DecodeKeywordStream')
'SherpaOnnxDecodeKeywordStream')
.asFunction();
getKeywordResultAsJson ??= dynamicLibrary
.lookup<NativeFunction<GetKeywordResultAsJsonNative>>(
'GetKeywordResultAsJson')
'SherpaOnnxGetKeywordResultAsJson')
.asFunction();
freeKeywordResultJson ??= dynamicLibrary
.lookup<NativeFunction<FreeKeywordResultJsonNative>>(
'FreeKeywordResultJson')
'SherpaOnnxFreeKeywordResultJson')
.asFunction();
createOfflineTts ??= dynamicLibrary
@@ -1031,88 +1037,91 @@ class SherpaOnnxBindings {
createOfflineRecognizer ??= dynamicLibrary
.lookup<NativeFunction<CreateOfflineRecognizerNative>>(
'CreateOfflineRecognizer')
'SherpaOnnxCreateOfflineRecognizer')
.asFunction();
destroyOfflineRecognizer ??= dynamicLibrary
.lookup<NativeFunction<DestroyOfflineRecognizerNative>>(
'DestroyOfflineRecognizer')
'SherpaOnnxDestroyOfflineRecognizer')
.asFunction();
createOfflineStream ??= dynamicLibrary
.lookup<NativeFunction<CreateOfflineStreamNative>>(
'CreateOfflineStream')
'SherpaOnnxCreateOfflineStream')
.asFunction();
destroyOfflineStream ??= dynamicLibrary
.lookup<NativeFunction<DestroyOfflineStreamNative>>(
'DestroyOfflineStream')
'SherpaOnnxDestroyOfflineStream')
.asFunction();
acceptWaveformOffline ??= dynamicLibrary
.lookup<NativeFunction<AcceptWaveformOfflineNative>>(
'AcceptWaveformOffline')
'SherpaOnnxAcceptWaveformOffline')
.asFunction();
decodeOfflineStream ??= dynamicLibrary
.lookup<NativeFunction<DecodeOfflineStreamNative>>(
'DecodeOfflineStream')
'SherpaOnnxDecodeOfflineStream')
.asFunction();
getOfflineStreamResultAsJson ??= dynamicLibrary
.lookup<NativeFunction<GetOfflineStreamResultAsJsonNative>>(
'GetOfflineStreamResultAsJson')
'SherpaOnnxGetOfflineStreamResultAsJson')
.asFunction();
destroyOfflineStreamResultJson ??= dynamicLibrary
.lookup<NativeFunction<DestroyOfflineStreamResultJsonNative>>(
'DestroyOfflineStreamResultJson')
'SherpaOnnxDestroyOfflineStreamResultJson')
.asFunction();
createOnlineRecognizer ??= dynamicLibrary
.lookup<NativeFunction<CreateOnlineRecognizerNative>>(
'CreateOnlineRecognizer')
.lookup<NativeFunction<SherpaOnnxCreateOnlineRecognizerNative>>(
'SherpaOnnxCreateOnlineRecognizer')
.asFunction();
destroyOnlineRecognizer ??= dynamicLibrary
.lookup<NativeFunction<DestroyOnlineRecognizerNative>>(
'DestroyOnlineRecognizer')
.lookup<NativeFunction<SherpaOnnxDestroyOnlineRecognizerNative>>(
'SherpaOnnxDestroyOnlineRecognizer')
.asFunction();
createOnlineStream ??= dynamicLibrary
.lookup<NativeFunction<CreateOnlineStreamNative>>('CreateOnlineStream')
.lookup<NativeFunction<SherpaOnnxCreateOnlineStreamNative>>(
'SherpaOnnxCreateOnlineStream')
.asFunction();
createOnlineStreamWithHotwords ??= dynamicLibrary
.lookup<NativeFunction<CreateOnlineStreamWithHotwordsNative>>(
'CreateOnlineStreamWithHotwords')
.lookup<NativeFunction<SherpaOnnxCreateOnlineStreamWithHotwordsNative>>(
'SherpaOnnxCreateOnlineStreamWithHotwords')
.asFunction();
isOnlineStreamReady ??= dynamicLibrary
.lookup<NativeFunction<IsOnlineStreamReadyNative>>(
'IsOnlineStreamReady')
'SherpaOnnxIsOnlineStreamReady')
.asFunction();
decodeOnlineStream ??= dynamicLibrary
.lookup<NativeFunction<DecodeOnlineStreamNative>>('DecodeOnlineStream')
.lookup<NativeFunction<SherpaOnnxDecodeOnlineStreamNative>>(
'SherpaOnnxDecodeOnlineStream')
.asFunction();
getOnlineStreamResultAsJson ??= dynamicLibrary
.lookup<NativeFunction<GetOnlineStreamResultAsJsonNative>>(
'GetOnlineStreamResultAsJson')
'SherpaOnnxGetOnlineStreamResultAsJson')
.asFunction();
reset ??= dynamicLibrary
.lookup<NativeFunction<ResetNative>>('Reset')
.lookup<NativeFunction<ResetNative>>('SherpaOnnxOnlineStreamReset')
.asFunction();
isEndpoint ??= dynamicLibrary
.lookup<NativeFunction<IsEndpointNative>>('IsEndpoint')
.lookup<NativeFunction<IsEndpointNative>>(
'SherpaOnnxOnlineStreamIsEndpoint')
.asFunction();
destroyOnlineStreamResultJson ??= dynamicLibrary
.lookup<NativeFunction<DestroyOnlineStreamResultJsonNative>>(
'DestroyOnlineStreamResultJson')
'SherpaOnnxDestroyOnlineStreamResultJson')
.asFunction();
createVoiceActivityDetector ??= dynamicLibrary
@@ -1258,18 +1267,18 @@ class SherpaOnnxBindings {
.asFunction();
destroyOnlineStream ??= dynamicLibrary
.lookup<NativeFunction<DestroyOnlineStreamNative>>(
'DestroyOnlineStream')
.lookup<NativeFunction<SherpaOnnxDestroyOnlineStreamNative>>(
'SherpaOnnxDestroyOnlineStream')
.asFunction();
onlineStreamAcceptWaveform ??= dynamicLibrary
.lookup<NativeFunction<OnlineStreamAcceptWaveformNative>>(
'AcceptWaveform')
'SherpaOnnxOnlineStreamAcceptWaveform')
.asFunction();
onlineStreamInputFinished ??= dynamicLibrary
.lookup<NativeFunction<OnlineStreamInputFinishedNative>>(
'InputFinished')
'SherpaOnnxOnlineStreamInputFinished')
.asFunction();
speakerEmbeddingExtractorIsReady ??= dynamicLibrary

View File

@@ -17,7 +17,7 @@ topics:
- voice-activity-detection
# remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
version: 1.10.18
version: 1.10.19
homepage: https://github.com/k2-fsa/sherpa-onnx
@@ -30,23 +30,23 @@ dependencies:
flutter:
sdk: flutter
sherpa_onnx_android: ^1.10.18
sherpa_onnx_android: ^1.10.19
# sherpa_onnx_android:
# path: ../sherpa_onnx_android
sherpa_onnx_macos: ^1.10.18
sherpa_onnx_macos: ^1.10.19
# sherpa_onnx_macos:
# path: ../sherpa_onnx_macos
sherpa_onnx_linux: ^1.10.18
sherpa_onnx_linux: ^1.10.19
# sherpa_onnx_linux:
# path: ../sherpa_onnx_linux
#
sherpa_onnx_windows: ^1.10.18
sherpa_onnx_windows: ^1.10.19
# sherpa_onnx_windows:
# path: ../sherpa_onnx_windows
sherpa_onnx_ios: ^1.10.18
sherpa_onnx_ios: ^1.10.19
# sherpa_onnx_ios:
# path: ../sherpa_onnx_ios

View File

@@ -7,7 +7,7 @@
# https://groups.google.com/g/dart-ffi/c/nUATMBy7r0c
Pod::Spec.new do |s|
s.name = 'sherpa_onnx_ios'
s.version = '1.10.18'
s.version = '1.10.19'
s.summary = 'A new Flutter FFI plugin project.'
s.description = <<-DESC
A new Flutter FFI plugin project.

View File

@@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'sherpa_onnx_macos'
s.version = '1.10.18'
s.version = '1.10.19'
s.summary = 'sherpa-onnx Flutter FFI plugin project.'
s.description = <<-DESC
sherpa-onnx Flutter FFI plugin project.