@gmessier/nitro-speech 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NitroSpeech.podspec +31 -0
- package/README.md +55 -0
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +148 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/nitrospeech/HybridNitroSpeech.kt +12 -0
- package/android/src/main/java/com/margelo/nitro/nitrospeech/NitroSpeechPackage.kt +20 -0
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/AudioPermissionRequester.kt +39 -0
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/AutoStopper.kt +35 -0
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/HybridRecognizer.kt +181 -0
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/RecognitionListenerSession.kt +106 -0
- package/ios/AppStateObserver.swift +31 -0
- package/ios/AutoStopper.swift +57 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridNitroSpeech.swift +6 -0
- package/ios/HybridRecognizer.swift +201 -0
- package/lib/commonjs/index.js +10 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/NitroSpeech.nitro.js +6 -0
- package/lib/commonjs/specs/NitroSpeech.nitro.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/specs/NitroSpeech.nitro.js +4 -0
- package/lib/module/specs/NitroSpeech.nitro.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/specs/NitroSpeech.nitro.d.ts +108 -0
- package/lib/typescript/specs/NitroSpeech.nitro.d.ts.map +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroSpeech+autolinking.cmake +83 -0
- package/nitrogen/generated/android/NitroSpeech+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroSpeechOnLoad.cpp +54 -0
- package/nitrogen/generated/android/NitroSpeechOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp +95 -0
- package/nitrogen/generated/android/c++/JHybridNitroSpeechSpec.cpp +59 -0
- package/nitrogen/generated/android/c++/JHybridNitroSpeechSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JHybridRecognizerSpec.cpp +167 -0
- package/nitrogen/generated/android/c++/JHybridRecognizerSpec.hpp +77 -0
- package/nitrogen/generated/android/c++/JSpeechToTextParams.hpp +109 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_std__string.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_std__vector_std__string_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridNitroSpeechSpec.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridRecognizerSpec.kt +143 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/NitroSpeechOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/SpeechToTextParams.kt +62 -0
- package/nitrogen/generated/ios/NitroSpeech+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.cpp +82 -0
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.hpp +291 -0
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Umbrella.hpp +55 -0
- package/nitrogen/generated/ios/NitroSpeechAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroSpeechAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridNitroSpeechSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroSpeechSpecSwift.hpp +77 -0
- package/nitrogen/generated/ios/c++/HybridRecognizerSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridRecognizerSpecSwift.hpp +126 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridNitroSpeechSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroSpeechSpec_cxx.swift +137 -0
- package/nitrogen/generated/ios/swift/HybridRecognizerSpec.swift +62 -0
- package/nitrogen/generated/ios/swift/HybridRecognizerSpec_cxx.swift +337 -0
- package/nitrogen/generated/ios/swift/SpeechToTextParams.swift +300 -0
- package/nitrogen/generated/shared/c++/HybridNitroSpeechSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroSpeechSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/HybridRecognizerSpec.cpp +34 -0
- package/nitrogen/generated/shared/c++/HybridRecognizerSpec.hpp +79 -0
- package/nitrogen/generated/shared/c++/SpeechToTextParams.hpp +109 -0
- package/package.json +123 -0
- package/react-native.config.js +16 -0
- package/src/index.ts +8 -0
- package/src/specs/NitroSpeech.nitro.ts +113 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSpeechToTextParams.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "SpeechToTextParams.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
#include <vector>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitrospeech {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The C++ JNI bridge between the C++ struct "SpeechToTextParams" and the the Kotlin data class "SpeechToTextParams".
|
|
23
|
+
*/
|
|
24
|
+
struct JSpeechToTextParams final: public jni::JavaClass<JSpeechToTextParams> {
|
|
25
|
+
public:
|
|
26
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/SpeechToTextParams;";
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Convert this Java/Kotlin-based struct to the C++ struct SpeechToTextParams by copying all values to C++.
|
|
31
|
+
*/
|
|
32
|
+
[[maybe_unused]]
|
|
33
|
+
[[nodiscard]]
|
|
34
|
+
SpeechToTextParams toCpp() const {
|
|
35
|
+
static const auto clazz = javaClassStatic();
|
|
36
|
+
static const auto fieldLocale = clazz->getField<jni::JString>("locale");
|
|
37
|
+
jni::local_ref<jni::JString> locale = this->getFieldValue(fieldLocale);
|
|
38
|
+
static const auto fieldAutoFinishRecognitionMs = clazz->getField<jni::JDouble>("autoFinishRecognitionMs");
|
|
39
|
+
jni::local_ref<jni::JDouble> autoFinishRecognitionMs = this->getFieldValue(fieldAutoFinishRecognitionMs);
|
|
40
|
+
static const auto fieldDisableRepeatingFilter = clazz->getField<jni::JBoolean>("disableRepeatingFilter");
|
|
41
|
+
jni::local_ref<jni::JBoolean> disableRepeatingFilter = this->getFieldValue(fieldDisableRepeatingFilter);
|
|
42
|
+
static const auto fieldContextualStrings = clazz->getField<jni::JArrayClass<jni::JString>>("contextualStrings");
|
|
43
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> contextualStrings = this->getFieldValue(fieldContextualStrings);
|
|
44
|
+
static const auto fieldAndroidMaskOffensiveWords = clazz->getField<jni::JBoolean>("androidMaskOffensiveWords");
|
|
45
|
+
jni::local_ref<jni::JBoolean> androidMaskOffensiveWords = this->getFieldValue(fieldAndroidMaskOffensiveWords);
|
|
46
|
+
static const auto fieldAndroidFormattingPreferQuality = clazz->getField<jni::JBoolean>("androidFormattingPreferQuality");
|
|
47
|
+
jni::local_ref<jni::JBoolean> androidFormattingPreferQuality = this->getFieldValue(fieldAndroidFormattingPreferQuality);
|
|
48
|
+
static const auto fieldAndroidUseWebSearchModel = clazz->getField<jni::JBoolean>("androidUseWebSearchModel");
|
|
49
|
+
jni::local_ref<jni::JBoolean> androidUseWebSearchModel = this->getFieldValue(fieldAndroidUseWebSearchModel);
|
|
50
|
+
static const auto fieldAndroidDisableBatchHandling = clazz->getField<jni::JBoolean>("androidDisableBatchHandling");
|
|
51
|
+
jni::local_ref<jni::JBoolean> androidDisableBatchHandling = this->getFieldValue(fieldAndroidDisableBatchHandling);
|
|
52
|
+
static const auto fieldIosAddPunctuation = clazz->getField<jni::JBoolean>("iosAddPunctuation");
|
|
53
|
+
jni::local_ref<jni::JBoolean> iosAddPunctuation = this->getFieldValue(fieldIosAddPunctuation);
|
|
54
|
+
return SpeechToTextParams(
|
|
55
|
+
locale != nullptr ? std::make_optional(locale->toStdString()) : std::nullopt,
|
|
56
|
+
autoFinishRecognitionMs != nullptr ? std::make_optional(autoFinishRecognitionMs->value()) : std::nullopt,
|
|
57
|
+
disableRepeatingFilter != nullptr ? std::make_optional(static_cast<bool>(disableRepeatingFilter->value())) : std::nullopt,
|
|
58
|
+
contextualStrings != nullptr ? std::make_optional([&]() {
|
|
59
|
+
size_t __size = contextualStrings->size();
|
|
60
|
+
std::vector<std::string> __vector;
|
|
61
|
+
__vector.reserve(__size);
|
|
62
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
63
|
+
auto __element = contextualStrings->getElement(__i);
|
|
64
|
+
__vector.push_back(__element->toStdString());
|
|
65
|
+
}
|
|
66
|
+
return __vector;
|
|
67
|
+
}()) : std::nullopt,
|
|
68
|
+
androidMaskOffensiveWords != nullptr ? std::make_optional(static_cast<bool>(androidMaskOffensiveWords->value())) : std::nullopt,
|
|
69
|
+
androidFormattingPreferQuality != nullptr ? std::make_optional(static_cast<bool>(androidFormattingPreferQuality->value())) : std::nullopt,
|
|
70
|
+
androidUseWebSearchModel != nullptr ? std::make_optional(static_cast<bool>(androidUseWebSearchModel->value())) : std::nullopt,
|
|
71
|
+
androidDisableBatchHandling != nullptr ? std::make_optional(static_cast<bool>(androidDisableBatchHandling->value())) : std::nullopt,
|
|
72
|
+
iosAddPunctuation != nullptr ? std::make_optional(static_cast<bool>(iosAddPunctuation->value())) : std::nullopt
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public:
|
|
77
|
+
/**
|
|
78
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
79
|
+
*/
|
|
80
|
+
[[maybe_unused]]
|
|
81
|
+
static jni::local_ref<JSpeechToTextParams::javaobject> fromCpp(const SpeechToTextParams& value) {
|
|
82
|
+
using JSignature = JSpeechToTextParams(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JArrayClass<jni::JString>>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>);
|
|
83
|
+
static const auto clazz = javaClassStatic();
|
|
84
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
85
|
+
return create(
|
|
86
|
+
clazz,
|
|
87
|
+
value.locale.has_value() ? jni::make_jstring(value.locale.value()) : nullptr,
|
|
88
|
+
value.autoFinishRecognitionMs.has_value() ? jni::JDouble::valueOf(value.autoFinishRecognitionMs.value()) : nullptr,
|
|
89
|
+
value.disableRepeatingFilter.has_value() ? jni::JBoolean::valueOf(value.disableRepeatingFilter.value()) : nullptr,
|
|
90
|
+
value.contextualStrings.has_value() ? [&]() {
|
|
91
|
+
size_t __size = value.contextualStrings.value().size();
|
|
92
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
93
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
94
|
+
const auto& __element = value.contextualStrings.value()[__i];
|
|
95
|
+
auto __elementJni = jni::make_jstring(__element);
|
|
96
|
+
__array->setElement(__i, *__elementJni);
|
|
97
|
+
}
|
|
98
|
+
return __array;
|
|
99
|
+
}() : nullptr,
|
|
100
|
+
value.androidMaskOffensiveWords.has_value() ? jni::JBoolean::valueOf(value.androidMaskOffensiveWords.value()) : nullptr,
|
|
101
|
+
value.androidFormattingPreferQuality.has_value() ? jni::JBoolean::valueOf(value.androidFormattingPreferQuality.value()) : nullptr,
|
|
102
|
+
value.androidUseWebSearchModel.has_value() ? jni::JBoolean::valueOf(value.androidUseWebSearchModel.value()) : nullptr,
|
|
103
|
+
value.androidDisableBatchHandling.has_value() ? jni::JBoolean::valueOf(value.androidDisableBatchHandling.value()) : nullptr,
|
|
104
|
+
value.iosAddPunctuation.has_value() ? jni::JBoolean::valueOf(value.iosAddPunctuation.value()) : nullptr
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
} // namespace margelo::nitro::nitrospeech
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrospeech
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `() => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void: () -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `() => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_cxx: Func_void {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(): Unit
|
|
60
|
+
= invoke_cxx()
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `() => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `() -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_java(private val function: () -> Unit): Func_void {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(): Unit {
|
|
78
|
+
return this.function()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_double.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrospeech
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `(timeLeftMs: number) => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void_double: (Double) -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(timeLeftMs: Double): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `(timeLeftMs: number) => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_double_cxx: Func_void_double {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(timeLeftMs: Double): Unit
|
|
60
|
+
= invoke_cxx(timeLeftMs)
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(timeLeftMs: Double): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `(timeLeftMs: number) => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `(Double) -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_double_java(private val function: (Double) -> Unit): Func_void_double {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(timeLeftMs: Double): Unit {
|
|
78
|
+
return this.function(timeLeftMs)
|
|
79
|
+
}
|
|
80
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_std__string.kt
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__string.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrospeech
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `(message: string) => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void_std__string: (String) -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(message: String): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `(message: string) => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_std__string_cxx: Func_void_std__string {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(message: String): Unit
|
|
60
|
+
= invoke_cxx(message)
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(message: String): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `(message: string) => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `(String) -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_std__string_java(private val function: (String) -> Unit): Func_void_std__string {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(message: String): Unit {
|
|
78
|
+
return this.function(message)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__vector_std__string_.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrospeech
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `(resultBatches: array) => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void_std__vector_std__string_: (Array<String>) -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(resultBatches: Array<String>): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `(resultBatches: array) => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_std__vector_std__string__cxx: Func_void_std__vector_std__string_ {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(resultBatches: Array<String>): Unit
|
|
60
|
+
= invoke_cxx(resultBatches)
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(resultBatches: Array<String>): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `(resultBatches: array) => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `(Array<String>) -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_std__vector_std__string__java(private val function: (Array<String>) -> Unit): Func_void_std__vector_std__string_ {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(resultBatches: Array<String>): Unit {
|
|
78
|
+
return this.function(resultBatches)
|
|
79
|
+
}
|
|
80
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridNitroSpeechSpec.kt
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSpeechSpec.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrospeech
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.HybridObject
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A Kotlin class representing the NitroSpeech HybridObject.
|
|
17
|
+
* Implement this abstract class to create Kotlin-based instances of NitroSpeech.
|
|
18
|
+
*/
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
@Keep
|
|
21
|
+
@Suppress(
|
|
22
|
+
"KotlinJniMissingFunction", "unused",
|
|
23
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
24
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
|
+
)
|
|
26
|
+
abstract class HybridNitroSpeechSpec: HybridObject() {
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
private var mHybridData: HybridData = initHybrid()
|
|
29
|
+
|
|
30
|
+
init {
|
|
31
|
+
super.updateNative(mHybridData)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun updateNative(hybridData: HybridData) {
|
|
35
|
+
mHybridData = hybridData
|
|
36
|
+
super.updateNative(hybridData)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Default implementation of `HybridObject.toString()`
|
|
40
|
+
override fun toString(): String {
|
|
41
|
+
return "[HybridObject NitroSpeech]"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Properties
|
|
45
|
+
@get:DoNotStrip
|
|
46
|
+
@get:Keep
|
|
47
|
+
@set:DoNotStrip
|
|
48
|
+
@set:Keep
|
|
49
|
+
abstract var recognizer: HybridRecognizerSpec
|
|
50
|
+
|
|
51
|
+
// Methods
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
private external fun initHybrid(): HybridData
|
|
55
|
+
|
|
56
|
+
companion object {
|
|
57
|
+
protected const val TAG = "HybridNitroSpeechSpec"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridRecognizerSpec.kt
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRecognizerSpec.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrospeech
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.HybridObject
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A Kotlin class representing the Recognizer HybridObject.
|
|
17
|
+
* Implement this abstract class to create Kotlin-based instances of Recognizer.
|
|
18
|
+
*/
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
@Keep
|
|
21
|
+
@Suppress(
|
|
22
|
+
"KotlinJniMissingFunction", "unused",
|
|
23
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
24
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
|
+
)
|
|
26
|
+
abstract class HybridRecognizerSpec: HybridObject() {
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
private var mHybridData: HybridData = initHybrid()
|
|
29
|
+
|
|
30
|
+
init {
|
|
31
|
+
super.updateNative(mHybridData)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun updateNative(hybridData: HybridData) {
|
|
35
|
+
mHybridData = hybridData
|
|
36
|
+
super.updateNative(hybridData)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Default implementation of `HybridObject.toString()`
|
|
40
|
+
override fun toString(): String {
|
|
41
|
+
return "[HybridObject Recognizer]"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Properties
|
|
45
|
+
abstract var onReadyForSpeech: (() -> Unit)?
|
|
46
|
+
|
|
47
|
+
private var onReadyForSpeech_cxx: Func_void?
|
|
48
|
+
@Keep
|
|
49
|
+
@DoNotStrip
|
|
50
|
+
get() {
|
|
51
|
+
return onReadyForSpeech?.let { Func_void_java(it) }
|
|
52
|
+
}
|
|
53
|
+
@Keep
|
|
54
|
+
@DoNotStrip
|
|
55
|
+
set(value) {
|
|
56
|
+
onReadyForSpeech = value?.let { it }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
abstract var onRecordingStopped: (() -> Unit)?
|
|
60
|
+
|
|
61
|
+
private var onRecordingStopped_cxx: Func_void?
|
|
62
|
+
@Keep
|
|
63
|
+
@DoNotStrip
|
|
64
|
+
get() {
|
|
65
|
+
return onRecordingStopped?.let { Func_void_java(it) }
|
|
66
|
+
}
|
|
67
|
+
@Keep
|
|
68
|
+
@DoNotStrip
|
|
69
|
+
set(value) {
|
|
70
|
+
onRecordingStopped = value?.let { it }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
abstract var onResult: ((resultBatches: Array<String>) -> Unit)?
|
|
74
|
+
|
|
75
|
+
private var onResult_cxx: Func_void_std__vector_std__string_?
|
|
76
|
+
@Keep
|
|
77
|
+
@DoNotStrip
|
|
78
|
+
get() {
|
|
79
|
+
return onResult?.let { Func_void_std__vector_std__string__java(it) }
|
|
80
|
+
}
|
|
81
|
+
@Keep
|
|
82
|
+
@DoNotStrip
|
|
83
|
+
set(value) {
|
|
84
|
+
onResult = value?.let { it }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
abstract var onAutoFinishProgress: ((timeLeftMs: Double) -> Unit)?
|
|
88
|
+
|
|
89
|
+
private var onAutoFinishProgress_cxx: Func_void_double?
|
|
90
|
+
@Keep
|
|
91
|
+
@DoNotStrip
|
|
92
|
+
get() {
|
|
93
|
+
return onAutoFinishProgress?.let { Func_void_double_java(it) }
|
|
94
|
+
}
|
|
95
|
+
@Keep
|
|
96
|
+
@DoNotStrip
|
|
97
|
+
set(value) {
|
|
98
|
+
onAutoFinishProgress = value?.let { it }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
abstract var onError: ((message: String) -> Unit)?
|
|
102
|
+
|
|
103
|
+
private var onError_cxx: Func_void_std__string?
|
|
104
|
+
@Keep
|
|
105
|
+
@DoNotStrip
|
|
106
|
+
get() {
|
|
107
|
+
return onError?.let { Func_void_std__string_java(it) }
|
|
108
|
+
}
|
|
109
|
+
@Keep
|
|
110
|
+
@DoNotStrip
|
|
111
|
+
set(value) {
|
|
112
|
+
onError = value?.let { it }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
abstract var onPermissionDenied: (() -> Unit)?
|
|
116
|
+
|
|
117
|
+
private var onPermissionDenied_cxx: Func_void?
|
|
118
|
+
@Keep
|
|
119
|
+
@DoNotStrip
|
|
120
|
+
get() {
|
|
121
|
+
return onPermissionDenied?.let { Func_void_java(it) }
|
|
122
|
+
}
|
|
123
|
+
@Keep
|
|
124
|
+
@DoNotStrip
|
|
125
|
+
set(value) {
|
|
126
|
+
onPermissionDenied = value?.let { it }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Methods
|
|
130
|
+
@DoNotStrip
|
|
131
|
+
@Keep
|
|
132
|
+
abstract fun startListening(params: SpeechToTextParams): Unit
|
|
133
|
+
|
|
134
|
+
@DoNotStrip
|
|
135
|
+
@Keep
|
|
136
|
+
abstract fun stopListening(): Unit
|
|
137
|
+
|
|
138
|
+
private external fun initHybrid(): HybridData
|
|
139
|
+
|
|
140
|
+
companion object {
|
|
141
|
+
protected const val TAG = "HybridRecognizerSpec"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroSpeechOnLoad.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrospeech
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class NitroSpeechOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "NitroSpeechOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "NitroSpeech".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading NitroSpeech C++ library...")
|
|
25
|
+
System.loadLibrary("NitroSpeech")
|
|
26
|
+
Log.i(TAG, "Successfully loaded NitroSpeech C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load NitroSpeech C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|