@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.
Files changed (85) hide show
  1. package/NitroSpeech.podspec +31 -0
  2. package/README.md +55 -0
  3. package/android/CMakeLists.txt +29 -0
  4. package/android/build.gradle +148 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +3 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/nitrospeech/HybridNitroSpeech.kt +12 -0
  10. package/android/src/main/java/com/margelo/nitro/nitrospeech/NitroSpeechPackage.kt +20 -0
  11. package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/AudioPermissionRequester.kt +39 -0
  12. package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/AutoStopper.kt +35 -0
  13. package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/HybridRecognizer.kt +181 -0
  14. package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/RecognitionListenerSession.kt +106 -0
  15. package/ios/AppStateObserver.swift +31 -0
  16. package/ios/AutoStopper.swift +57 -0
  17. package/ios/Bridge.h +8 -0
  18. package/ios/HybridNitroSpeech.swift +6 -0
  19. package/ios/HybridRecognizer.swift +201 -0
  20. package/lib/commonjs/index.js +10 -0
  21. package/lib/commonjs/index.js.map +1 -0
  22. package/lib/commonjs/package.json +1 -0
  23. package/lib/commonjs/specs/NitroSpeech.nitro.js +6 -0
  24. package/lib/commonjs/specs/NitroSpeech.nitro.js.map +1 -0
  25. package/lib/module/index.js +6 -0
  26. package/lib/module/index.js.map +1 -0
  27. package/lib/module/package.json +1 -0
  28. package/lib/module/specs/NitroSpeech.nitro.js +4 -0
  29. package/lib/module/specs/NitroSpeech.nitro.js.map +1 -0
  30. package/lib/tsconfig.tsbuildinfo +1 -0
  31. package/lib/typescript/index.d.ts +3 -0
  32. package/lib/typescript/index.d.ts.map +1 -0
  33. package/lib/typescript/specs/NitroSpeech.nitro.d.ts +108 -0
  34. package/lib/typescript/specs/NitroSpeech.nitro.d.ts.map +1 -0
  35. package/nitro.json +24 -0
  36. package/nitrogen/generated/.gitattributes +1 -0
  37. package/nitrogen/generated/android/NitroSpeech+autolinking.cmake +83 -0
  38. package/nitrogen/generated/android/NitroSpeech+autolinking.gradle +27 -0
  39. package/nitrogen/generated/android/NitroSpeechOnLoad.cpp +54 -0
  40. package/nitrogen/generated/android/NitroSpeechOnLoad.hpp +25 -0
  41. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  42. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  43. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  44. package/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp +95 -0
  45. package/nitrogen/generated/android/c++/JHybridNitroSpeechSpec.cpp +59 -0
  46. package/nitrogen/generated/android/c++/JHybridNitroSpeechSpec.hpp +66 -0
  47. package/nitrogen/generated/android/c++/JHybridRecognizerSpec.cpp +167 -0
  48. package/nitrogen/generated/android/c++/JHybridRecognizerSpec.hpp +77 -0
  49. package/nitrogen/generated/android/c++/JSpeechToTextParams.hpp +109 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void.kt +80 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_double.kt +80 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_std__string.kt +80 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_std__vector_std__string_.kt +80 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridNitroSpeechSpec.kt +59 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridRecognizerSpec.kt +143 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/NitroSpeechOnLoad.kt +35 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/SpeechToTextParams.kt +62 -0
  58. package/nitrogen/generated/ios/NitroSpeech+autolinking.rb +60 -0
  59. package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.cpp +82 -0
  60. package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.hpp +291 -0
  61. package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Umbrella.hpp +55 -0
  62. package/nitrogen/generated/ios/NitroSpeechAutolinking.mm +33 -0
  63. package/nitrogen/generated/ios/NitroSpeechAutolinking.swift +25 -0
  64. package/nitrogen/generated/ios/c++/HybridNitroSpeechSpecSwift.cpp +11 -0
  65. package/nitrogen/generated/ios/c++/HybridNitroSpeechSpecSwift.hpp +77 -0
  66. package/nitrogen/generated/ios/c++/HybridRecognizerSpecSwift.cpp +11 -0
  67. package/nitrogen/generated/ios/c++/HybridRecognizerSpecSwift.hpp +126 -0
  68. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  69. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  70. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  71. package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +47 -0
  72. package/nitrogen/generated/ios/swift/HybridNitroSpeechSpec.swift +56 -0
  73. package/nitrogen/generated/ios/swift/HybridNitroSpeechSpec_cxx.swift +137 -0
  74. package/nitrogen/generated/ios/swift/HybridRecognizerSpec.swift +62 -0
  75. package/nitrogen/generated/ios/swift/HybridRecognizerSpec_cxx.swift +337 -0
  76. package/nitrogen/generated/ios/swift/SpeechToTextParams.swift +300 -0
  77. package/nitrogen/generated/shared/c++/HybridNitroSpeechSpec.cpp +22 -0
  78. package/nitrogen/generated/shared/c++/HybridNitroSpeechSpec.hpp +65 -0
  79. package/nitrogen/generated/shared/c++/HybridRecognizerSpec.cpp +34 -0
  80. package/nitrogen/generated/shared/c++/HybridRecognizerSpec.hpp +79 -0
  81. package/nitrogen/generated/shared/c++/SpeechToTextParams.hpp +109 -0
  82. package/package.json +123 -0
  83. package/react-native.config.js +16 -0
  84. package/src/index.ts +8 -0
  85. package/src/specs/NitroSpeech.nitro.ts +113 -0
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void_double.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 <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::nitrospeech {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `(timeLeftMs: Double) -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void_double: public jni::JavaClass<JFunc_void_double> {
25
+ public:
26
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/Func_void_double;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void_double` instance holds through JNI.
31
+ */
32
+ void invoke(double timeLeftMs) const {
33
+ static const auto method = javaClassStatic()->getMethod<void(double /* timeLeftMs */)>("invoke");
34
+ method(self(), timeLeftMs);
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void_double that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_double_cxx final: public jni::HybridClass<JFunc_void_double_cxx, JFunc_void_double> {
42
+ public:
43
+ static jni::local_ref<JFunc_void_double::javaobject> fromCpp(const std::function<void(double /* timeLeftMs */)>& func) {
44
+ return JFunc_void_double_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_double_cxx` instance holds.
50
+ */
51
+ void invoke_cxx(double timeLeftMs) {
52
+ _func(timeLeftMs);
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void(double /* timeLeftMs */)>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/Func_void_double_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_double_cxx(const std::function<void(double /* timeLeftMs */)>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void(double /* timeLeftMs */)> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::nitrospeech
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// JFunc_void_std__string.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 <functional>
12
+
13
+ #include <string>
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+
17
+ namespace margelo::nitro::nitrospeech {
18
+
19
+ using namespace facebook;
20
+
21
+ /**
22
+ * Represents the Java/Kotlin callback `(message: String) -> Unit`.
23
+ * This can be passed around between C++ and Java/Kotlin.
24
+ */
25
+ struct JFunc_void_std__string: public jni::JavaClass<JFunc_void_std__string> {
26
+ public:
27
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/Func_void_std__string;";
28
+
29
+ public:
30
+ /**
31
+ * Invokes the function this `JFunc_void_std__string` instance holds through JNI.
32
+ */
33
+ void invoke(const std::string& message) const {
34
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* message */)>("invoke");
35
+ method(self(), jni::make_jstring(message));
36
+ }
37
+ };
38
+
39
+ /**
40
+ * An implementation of Func_void_std__string that is backed by a C++ implementation (using `std::function<...>`)
41
+ */
42
+ class JFunc_void_std__string_cxx final: public jni::HybridClass<JFunc_void_std__string_cxx, JFunc_void_std__string> {
43
+ public:
44
+ static jni::local_ref<JFunc_void_std__string::javaobject> fromCpp(const std::function<void(const std::string& /* message */)>& func) {
45
+ return JFunc_void_std__string_cxx::newObjectCxxArgs(func);
46
+ }
47
+
48
+ public:
49
+ /**
50
+ * Invokes the C++ `std::function<...>` this `JFunc_void_std__string_cxx` instance holds.
51
+ */
52
+ void invoke_cxx(jni::alias_ref<jni::JString> message) {
53
+ _func(message->toStdString());
54
+ }
55
+
56
+ public:
57
+ [[nodiscard]]
58
+ inline const std::function<void(const std::string& /* message */)>& getFunction() const {
59
+ return _func;
60
+ }
61
+
62
+ public:
63
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/Func_void_std__string_cxx;";
64
+ static void registerNatives() {
65
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__string_cxx::invoke_cxx)});
66
+ }
67
+
68
+ private:
69
+ explicit JFunc_void_std__string_cxx(const std::function<void(const std::string& /* message */)>& func): _func(func) { }
70
+
71
+ private:
72
+ friend HybridBase;
73
+ std::function<void(const std::string& /* message */)> _func;
74
+ };
75
+
76
+ } // namespace margelo::nitro::nitrospeech
@@ -0,0 +1,95 @@
1
+ ///
2
+ /// JFunc_void_std__vector_std__string_.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 <functional>
12
+
13
+ #include <string>
14
+ #include <vector>
15
+ #include <functional>
16
+ #include <NitroModules/JNICallable.hpp>
17
+
18
+ namespace margelo::nitro::nitrospeech {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * Represents the Java/Kotlin callback `(resultBatches: Array<String>) -> Unit`.
24
+ * This can be passed around between C++ and Java/Kotlin.
25
+ */
26
+ struct JFunc_void_std__vector_std__string_: public jni::JavaClass<JFunc_void_std__vector_std__string_> {
27
+ public:
28
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/Func_void_std__vector_std__string_;";
29
+
30
+ public:
31
+ /**
32
+ * Invokes the function this `JFunc_void_std__vector_std__string_` instance holds through JNI.
33
+ */
34
+ void invoke(const std::vector<std::string>& resultBatches) const {
35
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<jni::JString>> /* resultBatches */)>("invoke");
36
+ method(self(), [&]() {
37
+ size_t __size = resultBatches.size();
38
+ jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
39
+ for (size_t __i = 0; __i < __size; __i++) {
40
+ const auto& __element = resultBatches[__i];
41
+ auto __elementJni = jni::make_jstring(__element);
42
+ __array->setElement(__i, *__elementJni);
43
+ }
44
+ return __array;
45
+ }());
46
+ }
47
+ };
48
+
49
+ /**
50
+ * An implementation of Func_void_std__vector_std__string_ that is backed by a C++ implementation (using `std::function<...>`)
51
+ */
52
+ class JFunc_void_std__vector_std__string__cxx final: public jni::HybridClass<JFunc_void_std__vector_std__string__cxx, JFunc_void_std__vector_std__string_> {
53
+ public:
54
+ static jni::local_ref<JFunc_void_std__vector_std__string_::javaobject> fromCpp(const std::function<void(const std::vector<std::string>& /* resultBatches */)>& func) {
55
+ return JFunc_void_std__vector_std__string__cxx::newObjectCxxArgs(func);
56
+ }
57
+
58
+ public:
59
+ /**
60
+ * Invokes the C++ `std::function<...>` this `JFunc_void_std__vector_std__string__cxx` instance holds.
61
+ */
62
+ void invoke_cxx(jni::alias_ref<jni::JArrayClass<jni::JString>> resultBatches) {
63
+ _func([&]() {
64
+ size_t __size = resultBatches->size();
65
+ std::vector<std::string> __vector;
66
+ __vector.reserve(__size);
67
+ for (size_t __i = 0; __i < __size; __i++) {
68
+ auto __element = resultBatches->getElement(__i);
69
+ __vector.push_back(__element->toStdString());
70
+ }
71
+ return __vector;
72
+ }());
73
+ }
74
+
75
+ public:
76
+ [[nodiscard]]
77
+ inline const std::function<void(const std::vector<std::string>& /* resultBatches */)>& getFunction() const {
78
+ return _func;
79
+ }
80
+
81
+ public:
82
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/Func_void_std__vector_std__string__cxx;";
83
+ static void registerNatives() {
84
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__vector_std__string__cxx::invoke_cxx)});
85
+ }
86
+
87
+ private:
88
+ explicit JFunc_void_std__vector_std__string__cxx(const std::function<void(const std::vector<std::string>& /* resultBatches */)>& func): _func(func) { }
89
+
90
+ private:
91
+ friend HybridBase;
92
+ std::function<void(const std::vector<std::string>& /* resultBatches */)> _func;
93
+ };
94
+
95
+ } // namespace margelo::nitro::nitrospeech
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// JHybridNitroSpeechSpec.cpp
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
+ #include "JHybridNitroSpeechSpec.hpp"
9
+
10
+ // Forward declaration of `HybridRecognizerSpec` to properly resolve imports.
11
+ namespace margelo::nitro::nitrospeech { class HybridRecognizerSpec; }
12
+
13
+ #include <memory>
14
+ #include "HybridRecognizerSpec.hpp"
15
+ #include "JHybridRecognizerSpec.hpp"
16
+
17
+ namespace margelo::nitro::nitrospeech {
18
+
19
+ jni::local_ref<JHybridNitroSpeechSpec::jhybriddata> JHybridNitroSpeechSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
20
+ return makeCxxInstance(jThis);
21
+ }
22
+
23
+ void JHybridNitroSpeechSpec::registerNatives() {
24
+ registerHybrid({
25
+ makeNativeMethod("initHybrid", JHybridNitroSpeechSpec::initHybrid),
26
+ });
27
+ }
28
+
29
+ size_t JHybridNitroSpeechSpec::getExternalMemorySize() noexcept {
30
+ static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
31
+ return method(_javaPart);
32
+ }
33
+
34
+ void JHybridNitroSpeechSpec::dispose() noexcept {
35
+ static const auto method = javaClassStatic()->getMethod<void()>("dispose");
36
+ method(_javaPart);
37
+ }
38
+
39
+ std::string JHybridNitroSpeechSpec::toString() {
40
+ static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
41
+ auto javaString = method(_javaPart);
42
+ return javaString->toStdString();
43
+ }
44
+
45
+ // Properties
46
+ std::shared_ptr<HybridRecognizerSpec> JHybridNitroSpeechSpec::getRecognizer() {
47
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JHybridRecognizerSpec::javaobject>()>("getRecognizer");
48
+ auto __result = method(_javaPart);
49
+ return __result->cthis()->shared_cast<JHybridRecognizerSpec>();
50
+ }
51
+ void JHybridNitroSpeechSpec::setRecognizer(const std::shared_ptr<HybridRecognizerSpec>& recognizer) {
52
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHybridRecognizerSpec::javaobject> /* recognizer */)>("setRecognizer");
53
+ method(_javaPart, std::dynamic_pointer_cast<JHybridRecognizerSpec>(recognizer)->getJavaPart());
54
+ }
55
+
56
+ // Methods
57
+
58
+
59
+ } // namespace margelo::nitro::nitrospeech
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// HybridNitroSpeechSpec.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 <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridNitroSpeechSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::nitrospeech {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridNitroSpeechSpec: public jni::HybridClass<JHybridNitroSpeechSpec, JHybridObject>,
22
+ public virtual HybridNitroSpeechSpec {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/HybridNitroSpeechSpec;";
25
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
26
+ static void registerNatives();
27
+
28
+ protected:
29
+ // C++ constructor (called from Java via `initHybrid()`)
30
+ explicit JHybridNitroSpeechSpec(jni::alias_ref<jhybridobject> jThis) :
31
+ HybridObject(HybridNitroSpeechSpec::TAG),
32
+ HybridBase(jThis),
33
+ _javaPart(jni::make_global(jThis)) {}
34
+
35
+ public:
36
+ ~JHybridNitroSpeechSpec() override {
37
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
38
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39
+ }
40
+
41
+ public:
42
+ size_t getExternalMemorySize() noexcept override;
43
+ void dispose() noexcept override;
44
+ std::string toString() override;
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridNitroSpeechSpec::javaobject>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+ std::shared_ptr<HybridRecognizerSpec> getRecognizer() override;
54
+ void setRecognizer(const std::shared_ptr<HybridRecognizerSpec>& recognizer) override;
55
+
56
+ public:
57
+ // Methods
58
+
59
+
60
+ private:
61
+ friend HybridBase;
62
+ using HybridBase::HybridBase;
63
+ jni::global_ref<JHybridNitroSpeechSpec::javaobject> _javaPart;
64
+ };
65
+
66
+ } // namespace margelo::nitro::nitrospeech
@@ -0,0 +1,167 @@
1
+ ///
2
+ /// JHybridRecognizerSpec.cpp
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
+ #include "JHybridRecognizerSpec.hpp"
9
+
10
+ // Forward declaration of `SpeechToTextParams` to properly resolve imports.
11
+ namespace margelo::nitro::nitrospeech { struct SpeechToTextParams; }
12
+
13
+ #include <functional>
14
+ #include <optional>
15
+ #include "JFunc_void.hpp"
16
+ #include <NitroModules/JNICallable.hpp>
17
+ #include <string>
18
+ #include <vector>
19
+ #include "JFunc_void_std__vector_std__string_.hpp"
20
+ #include "JFunc_void_double.hpp"
21
+ #include "JFunc_void_std__string.hpp"
22
+ #include "SpeechToTextParams.hpp"
23
+ #include "JSpeechToTextParams.hpp"
24
+
25
+ namespace margelo::nitro::nitrospeech {
26
+
27
+ jni::local_ref<JHybridRecognizerSpec::jhybriddata> JHybridRecognizerSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
28
+ return makeCxxInstance(jThis);
29
+ }
30
+
31
+ void JHybridRecognizerSpec::registerNatives() {
32
+ registerHybrid({
33
+ makeNativeMethod("initHybrid", JHybridRecognizerSpec::initHybrid),
34
+ });
35
+ }
36
+
37
+ size_t JHybridRecognizerSpec::getExternalMemorySize() noexcept {
38
+ static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
39
+ return method(_javaPart);
40
+ }
41
+
42
+ void JHybridRecognizerSpec::dispose() noexcept {
43
+ static const auto method = javaClassStatic()->getMethod<void()>("dispose");
44
+ method(_javaPart);
45
+ }
46
+
47
+ std::string JHybridRecognizerSpec::toString() {
48
+ static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
49
+ auto javaString = method(_javaPart);
50
+ return javaString->toStdString();
51
+ }
52
+
53
+ // Properties
54
+ std::optional<std::function<void()>> JHybridRecognizerSpec::getOnReadyForSpeech() {
55
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnReadyForSpeech_cxx");
56
+ auto __result = method(_javaPart);
57
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
58
+ if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
59
+ auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
60
+ return downcast->cthis()->getFunction();
61
+ } else {
62
+ auto __resultRef = jni::make_global(__result);
63
+ return JNICallable<JFunc_void, void()>(std::move(__resultRef));
64
+ }
65
+ }()) : std::nullopt;
66
+ }
67
+ void JHybridRecognizerSpec::setOnReadyForSpeech(const std::optional<std::function<void()>>& onReadyForSpeech) {
68
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onReadyForSpeech */)>("setOnReadyForSpeech_cxx");
69
+ method(_javaPart, onReadyForSpeech.has_value() ? JFunc_void_cxx::fromCpp(onReadyForSpeech.value()) : nullptr);
70
+ }
71
+ std::optional<std::function<void()>> JHybridRecognizerSpec::getOnRecordingStopped() {
72
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnRecordingStopped_cxx");
73
+ auto __result = method(_javaPart);
74
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
75
+ if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
76
+ auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
77
+ return downcast->cthis()->getFunction();
78
+ } else {
79
+ auto __resultRef = jni::make_global(__result);
80
+ return JNICallable<JFunc_void, void()>(std::move(__resultRef));
81
+ }
82
+ }()) : std::nullopt;
83
+ }
84
+ void JHybridRecognizerSpec::setOnRecordingStopped(const std::optional<std::function<void()>>& onRecordingStopped) {
85
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onRecordingStopped */)>("setOnRecordingStopped_cxx");
86
+ method(_javaPart, onRecordingStopped.has_value() ? JFunc_void_cxx::fromCpp(onRecordingStopped.value()) : nullptr);
87
+ }
88
+ std::optional<std::function<void(const std::vector<std::string>& /* resultBatches */)>> JHybridRecognizerSpec::getOnResult() {
89
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__vector_std__string_::javaobject>()>("getOnResult_cxx");
90
+ auto __result = method(_javaPart);
91
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::vector<std::string>& /* resultBatches */)> {
92
+ if (__result->isInstanceOf(JFunc_void_std__vector_std__string__cxx::javaClassStatic())) [[likely]] {
93
+ auto downcast = jni::static_ref_cast<JFunc_void_std__vector_std__string__cxx::javaobject>(__result);
94
+ return downcast->cthis()->getFunction();
95
+ } else {
96
+ auto __resultRef = jni::make_global(__result);
97
+ return JNICallable<JFunc_void_std__vector_std__string_, void(std::vector<std::string>)>(std::move(__resultRef));
98
+ }
99
+ }()) : std::nullopt;
100
+ }
101
+ void JHybridRecognizerSpec::setOnResult(const std::optional<std::function<void(const std::vector<std::string>& /* resultBatches */)>>& onResult) {
102
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__vector_std__string_::javaobject> /* onResult */)>("setOnResult_cxx");
103
+ method(_javaPart, onResult.has_value() ? JFunc_void_std__vector_std__string__cxx::fromCpp(onResult.value()) : nullptr);
104
+ }
105
+ std::optional<std::function<void(double /* timeLeftMs */)>> JHybridRecognizerSpec::getOnAutoFinishProgress() {
106
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_double::javaobject>()>("getOnAutoFinishProgress_cxx");
107
+ auto __result = method(_javaPart);
108
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(double /* timeLeftMs */)> {
109
+ if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] {
110
+ auto downcast = jni::static_ref_cast<JFunc_void_double_cxx::javaobject>(__result);
111
+ return downcast->cthis()->getFunction();
112
+ } else {
113
+ auto __resultRef = jni::make_global(__result);
114
+ return JNICallable<JFunc_void_double, void(double)>(std::move(__resultRef));
115
+ }
116
+ }()) : std::nullopt;
117
+ }
118
+ void JHybridRecognizerSpec::setOnAutoFinishProgress(const std::optional<std::function<void(double /* timeLeftMs */)>>& onAutoFinishProgress) {
119
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_double::javaobject> /* onAutoFinishProgress */)>("setOnAutoFinishProgress_cxx");
120
+ method(_javaPart, onAutoFinishProgress.has_value() ? JFunc_void_double_cxx::fromCpp(onAutoFinishProgress.value()) : nullptr);
121
+ }
122
+ std::optional<std::function<void(const std::string& /* message */)>> JHybridRecognizerSpec::getOnError() {
123
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnError_cxx");
124
+ auto __result = method(_javaPart);
125
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* message */)> {
126
+ if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
127
+ auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
128
+ return downcast->cthis()->getFunction();
129
+ } else {
130
+ auto __resultRef = jni::make_global(__result);
131
+ return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
132
+ }
133
+ }()) : std::nullopt;
134
+ }
135
+ void JHybridRecognizerSpec::setOnError(const std::optional<std::function<void(const std::string& /* message */)>>& onError) {
136
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onError */)>("setOnError_cxx");
137
+ method(_javaPart, onError.has_value() ? JFunc_void_std__string_cxx::fromCpp(onError.value()) : nullptr);
138
+ }
139
+ std::optional<std::function<void()>> JHybridRecognizerSpec::getOnPermissionDenied() {
140
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnPermissionDenied_cxx");
141
+ auto __result = method(_javaPart);
142
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
143
+ if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
144
+ auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
145
+ return downcast->cthis()->getFunction();
146
+ } else {
147
+ auto __resultRef = jni::make_global(__result);
148
+ return JNICallable<JFunc_void, void()>(std::move(__resultRef));
149
+ }
150
+ }()) : std::nullopt;
151
+ }
152
+ void JHybridRecognizerSpec::setOnPermissionDenied(const std::optional<std::function<void()>>& onPermissionDenied) {
153
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onPermissionDenied */)>("setOnPermissionDenied_cxx");
154
+ method(_javaPart, onPermissionDenied.has_value() ? JFunc_void_cxx::fromCpp(onPermissionDenied.value()) : nullptr);
155
+ }
156
+
157
+ // Methods
158
+ void JHybridRecognizerSpec::startListening(const SpeechToTextParams& params) {
159
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSpeechToTextParams> /* params */)>("startListening");
160
+ method(_javaPart, JSpeechToTextParams::fromCpp(params));
161
+ }
162
+ void JHybridRecognizerSpec::stopListening() {
163
+ static const auto method = javaClassStatic()->getMethod<void()>("stopListening");
164
+ method(_javaPart);
165
+ }
166
+
167
+ } // namespace margelo::nitro::nitrospeech
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// HybridRecognizerSpec.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 <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridRecognizerSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::nitrospeech {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridRecognizerSpec: public jni::HybridClass<JHybridRecognizerSpec, JHybridObject>,
22
+ public virtual HybridRecognizerSpec {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/HybridRecognizerSpec;";
25
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
26
+ static void registerNatives();
27
+
28
+ protected:
29
+ // C++ constructor (called from Java via `initHybrid()`)
30
+ explicit JHybridRecognizerSpec(jni::alias_ref<jhybridobject> jThis) :
31
+ HybridObject(HybridRecognizerSpec::TAG),
32
+ HybridBase(jThis),
33
+ _javaPart(jni::make_global(jThis)) {}
34
+
35
+ public:
36
+ ~JHybridRecognizerSpec() override {
37
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
38
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39
+ }
40
+
41
+ public:
42
+ size_t getExternalMemorySize() noexcept override;
43
+ void dispose() noexcept override;
44
+ std::string toString() override;
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridRecognizerSpec::javaobject>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+ std::optional<std::function<void()>> getOnReadyForSpeech() override;
54
+ void setOnReadyForSpeech(const std::optional<std::function<void()>>& onReadyForSpeech) override;
55
+ std::optional<std::function<void()>> getOnRecordingStopped() override;
56
+ void setOnRecordingStopped(const std::optional<std::function<void()>>& onRecordingStopped) override;
57
+ std::optional<std::function<void(const std::vector<std::string>& /* resultBatches */)>> getOnResult() override;
58
+ void setOnResult(const std::optional<std::function<void(const std::vector<std::string>& /* resultBatches */)>>& onResult) override;
59
+ std::optional<std::function<void(double /* timeLeftMs */)>> getOnAutoFinishProgress() override;
60
+ void setOnAutoFinishProgress(const std::optional<std::function<void(double /* timeLeftMs */)>>& onAutoFinishProgress) override;
61
+ std::optional<std::function<void(const std::string& /* message */)>> getOnError() override;
62
+ void setOnError(const std::optional<std::function<void(const std::string& /* message */)>>& onError) override;
63
+ std::optional<std::function<void()>> getOnPermissionDenied() override;
64
+ void setOnPermissionDenied(const std::optional<std::function<void()>>& onPermissionDenied) override;
65
+
66
+ public:
67
+ // Methods
68
+ void startListening(const SpeechToTextParams& params) override;
69
+ void stopListening() override;
70
+
71
+ private:
72
+ friend HybridBase;
73
+ using HybridBase::HybridBase;
74
+ jni::global_ref<JHybridRecognizerSpec::javaobject> _javaPart;
75
+ };
76
+
77
+ } // namespace margelo::nitro::nitrospeech