@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,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSpeechSpecSwift.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 "HybridNitroSpeechSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridNitroSpeechSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroSpeech { class HybridNitroSpeechSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `HybridRecognizerSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrospeech { class HybridRecognizerSpec; }
|
|
17
|
+
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include "HybridRecognizerSpec.hpp"
|
|
20
|
+
|
|
21
|
+
#include "NitroSpeech-Swift-Cxx-Umbrella.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::nitrospeech {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The C++ part of HybridNitroSpeechSpec_cxx.swift.
|
|
27
|
+
*
|
|
28
|
+
* HybridNitroSpeechSpecSwift (C++) accesses HybridNitroSpeechSpec_cxx (Swift), and might
|
|
29
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
30
|
+
*
|
|
31
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
32
|
+
* the future, HybridNitroSpeechSpec_cxx can directly inherit from the C++ class HybridNitroSpeechSpec
|
|
33
|
+
* to simplify the whole structure and memory management.
|
|
34
|
+
*/
|
|
35
|
+
class HybridNitroSpeechSpecSwift: public virtual HybridNitroSpeechSpec {
|
|
36
|
+
public:
|
|
37
|
+
// Constructor from a Swift instance
|
|
38
|
+
explicit HybridNitroSpeechSpecSwift(const NitroSpeech::HybridNitroSpeechSpec_cxx& swiftPart):
|
|
39
|
+
HybridObject(HybridNitroSpeechSpec::TAG),
|
|
40
|
+
_swiftPart(swiftPart) { }
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
// Get the Swift part
|
|
44
|
+
inline NitroSpeech::HybridNitroSpeechSpec_cxx& getSwiftPart() noexcept {
|
|
45
|
+
return _swiftPart;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
50
|
+
return _swiftPart.getMemorySize();
|
|
51
|
+
}
|
|
52
|
+
void dispose() noexcept override {
|
|
53
|
+
_swiftPart.dispose();
|
|
54
|
+
}
|
|
55
|
+
std::string toString() override {
|
|
56
|
+
return _swiftPart.toString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
// Properties
|
|
61
|
+
inline std::shared_ptr<HybridRecognizerSpec> getRecognizer() noexcept override {
|
|
62
|
+
auto __result = _swiftPart.getRecognizer();
|
|
63
|
+
return __result;
|
|
64
|
+
}
|
|
65
|
+
inline void setRecognizer(const std::shared_ptr<HybridRecognizerSpec>& recognizer) noexcept override {
|
|
66
|
+
_swiftPart.setRecognizer(recognizer);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
// Methods
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
NitroSpeech::HybridNitroSpeechSpec_cxx _swiftPart;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::nitrospeech
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRecognizerSpecSwift.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 "HybridRecognizerSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitrospeech {
|
|
11
|
+
} // namespace margelo::nitro::nitrospeech
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRecognizerSpecSwift.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 "HybridRecognizerSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridRecognizerSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroSpeech { class HybridRecognizerSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `SpeechToTextParams` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrospeech { struct SpeechToTextParams; }
|
|
17
|
+
|
|
18
|
+
#include <functional>
|
|
19
|
+
#include <optional>
|
|
20
|
+
#include <string>
|
|
21
|
+
#include <vector>
|
|
22
|
+
#include "SpeechToTextParams.hpp"
|
|
23
|
+
|
|
24
|
+
#include "NitroSpeech-Swift-Cxx-Umbrella.hpp"
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitrospeech {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The C++ part of HybridRecognizerSpec_cxx.swift.
|
|
30
|
+
*
|
|
31
|
+
* HybridRecognizerSpecSwift (C++) accesses HybridRecognizerSpec_cxx (Swift), and might
|
|
32
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
33
|
+
*
|
|
34
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
35
|
+
* the future, HybridRecognizerSpec_cxx can directly inherit from the C++ class HybridRecognizerSpec
|
|
36
|
+
* to simplify the whole structure and memory management.
|
|
37
|
+
*/
|
|
38
|
+
class HybridRecognizerSpecSwift: public virtual HybridRecognizerSpec {
|
|
39
|
+
public:
|
|
40
|
+
// Constructor from a Swift instance
|
|
41
|
+
explicit HybridRecognizerSpecSwift(const NitroSpeech::HybridRecognizerSpec_cxx& swiftPart):
|
|
42
|
+
HybridObject(HybridRecognizerSpec::TAG),
|
|
43
|
+
_swiftPart(swiftPart) { }
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
// Get the Swift part
|
|
47
|
+
inline NitroSpeech::HybridRecognizerSpec_cxx& getSwiftPart() noexcept {
|
|
48
|
+
return _swiftPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
53
|
+
return _swiftPart.getMemorySize();
|
|
54
|
+
}
|
|
55
|
+
void dispose() noexcept override {
|
|
56
|
+
_swiftPart.dispose();
|
|
57
|
+
}
|
|
58
|
+
std::string toString() override {
|
|
59
|
+
return _swiftPart.toString();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
// Properties
|
|
64
|
+
inline std::optional<std::function<void()>> getOnReadyForSpeech() noexcept override {
|
|
65
|
+
auto __result = _swiftPart.getOnReadyForSpeech();
|
|
66
|
+
return __result;
|
|
67
|
+
}
|
|
68
|
+
inline void setOnReadyForSpeech(const std::optional<std::function<void()>>& onReadyForSpeech) noexcept override {
|
|
69
|
+
_swiftPart.setOnReadyForSpeech(onReadyForSpeech);
|
|
70
|
+
}
|
|
71
|
+
inline std::optional<std::function<void()>> getOnRecordingStopped() noexcept override {
|
|
72
|
+
auto __result = _swiftPart.getOnRecordingStopped();
|
|
73
|
+
return __result;
|
|
74
|
+
}
|
|
75
|
+
inline void setOnRecordingStopped(const std::optional<std::function<void()>>& onRecordingStopped) noexcept override {
|
|
76
|
+
_swiftPart.setOnRecordingStopped(onRecordingStopped);
|
|
77
|
+
}
|
|
78
|
+
inline std::optional<std::function<void(const std::vector<std::string>& /* resultBatches */)>> getOnResult() noexcept override {
|
|
79
|
+
auto __result = _swiftPart.getOnResult();
|
|
80
|
+
return __result;
|
|
81
|
+
}
|
|
82
|
+
inline void setOnResult(const std::optional<std::function<void(const std::vector<std::string>& /* resultBatches */)>>& onResult) noexcept override {
|
|
83
|
+
_swiftPart.setOnResult(onResult);
|
|
84
|
+
}
|
|
85
|
+
inline std::optional<std::function<void(double /* timeLeftMs */)>> getOnAutoFinishProgress() noexcept override {
|
|
86
|
+
auto __result = _swiftPart.getOnAutoFinishProgress();
|
|
87
|
+
return __result;
|
|
88
|
+
}
|
|
89
|
+
inline void setOnAutoFinishProgress(const std::optional<std::function<void(double /* timeLeftMs */)>>& onAutoFinishProgress) noexcept override {
|
|
90
|
+
_swiftPart.setOnAutoFinishProgress(onAutoFinishProgress);
|
|
91
|
+
}
|
|
92
|
+
inline std::optional<std::function<void(const std::string& /* message */)>> getOnError() noexcept override {
|
|
93
|
+
auto __result = _swiftPart.getOnError();
|
|
94
|
+
return __result;
|
|
95
|
+
}
|
|
96
|
+
inline void setOnError(const std::optional<std::function<void(const std::string& /* message */)>>& onError) noexcept override {
|
|
97
|
+
_swiftPart.setOnError(onError);
|
|
98
|
+
}
|
|
99
|
+
inline std::optional<std::function<void()>> getOnPermissionDenied() noexcept override {
|
|
100
|
+
auto __result = _swiftPart.getOnPermissionDenied();
|
|
101
|
+
return __result;
|
|
102
|
+
}
|
|
103
|
+
inline void setOnPermissionDenied(const std::optional<std::function<void()>>& onPermissionDenied) noexcept override {
|
|
104
|
+
_swiftPart.setOnPermissionDenied(onPermissionDenied);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public:
|
|
108
|
+
// Methods
|
|
109
|
+
inline void startListening(const SpeechToTextParams& params) override {
|
|
110
|
+
auto __result = _swiftPart.startListening(std::forward<decltype(params)>(params));
|
|
111
|
+
if (__result.hasError()) [[unlikely]] {
|
|
112
|
+
std::rethrow_exception(__result.error());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
inline void stopListening() override {
|
|
116
|
+
auto __result = _swiftPart.stopListening();
|
|
117
|
+
if (__result.hasError()) [[unlikely]] {
|
|
118
|
+
std::rethrow_exception(__result.error());
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private:
|
|
123
|
+
NitroSpeech::HybridRecognizerSpec_cxx _swiftPart;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
} // namespace margelo::nitro::nitrospeech
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `() -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void {
|
|
16
|
+
public typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: () -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping () -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call() -> Void {
|
|
26
|
+
self.closure()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
|
|
45
|
+
return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_double.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ timeLeftMs: Double) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_double {
|
|
16
|
+
public typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ timeLeftMs: Double) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ timeLeftMs: Double) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(timeLeftMs: Double) -> Void {
|
|
26
|
+
self.closure(timeLeftMs)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_double`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_double>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double {
|
|
45
|
+
return Unmanaged<Func_void_double>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__string.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ message: String) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__string {
|
|
16
|
+
public typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ message: String) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ message: String) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(message: std.string) -> Void {
|
|
26
|
+
self.closure(String(message))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_std__string`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
|
|
45
|
+
return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__vector_std__string_.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ resultBatches: [String]) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__vector_std__string_ {
|
|
16
|
+
public typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ resultBatches: [String]) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ resultBatches: [String]) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(resultBatches: bridge.std__vector_std__string_) -> Void {
|
|
26
|
+
self.closure(resultBatches.map({ __item in String(__item) }))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_std__vector_std__string_`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_std__string_>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_std__string_ {
|
|
45
|
+
return Unmanaged<Func_void_std__vector_std__string_>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSpeechSpec.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridNitroSpeechSpec``
|
|
12
|
+
public protocol HybridNitroSpeechSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
var recognizer: (any HybridRecognizerSpec) { get set }
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridNitroSpeechSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject NitroSpeech]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridNitroSpeechSpec``
|
|
28
|
+
open class HybridNitroSpeechSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridNitroSpeechSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridNitroSpeechSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is HybridNitroSpeechSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridNitroSpeechSpec`! Did you accidentally inherit from `HybridNitroSpeechSpec_base` instead of `HybridNitroSpeechSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridNitroSpeechSpec_cxx(self as! HybridNitroSpeechSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the NitroSpeech HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of NitroSpeech.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridNitroSpeech : HybridNitroSpeechSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridNitroSpeechSpec = HybridNitroSpeechSpec_protocol & HybridNitroSpeechSpec_base
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSpeechSpec_cxx.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridNitroSpeechSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridNitroSpeechSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::nitrospeech::bridge::swift`)
|
|
23
|
+
* from `NitroSpeech-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridNitroSpeechSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridNitroSpeechSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridNitroSpeechSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridNitroSpeechSpec_cxx` that wraps the given `HybridNitroSpeechSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridNitroSpeechSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridNitroSpeechSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridNitroSpeechSpec() -> any HybridNitroSpeechSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridNitroSpeechSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridNitroSpeechSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroSpeechSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridNitroSpeechSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridNitroSpeechSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroSpeechSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridNitroSpeechSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridNitroSpeechSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
public final var recognizer: bridge.std__shared_ptr_HybridRecognizerSpec_ {
|
|
118
|
+
@inline(__always)
|
|
119
|
+
get {
|
|
120
|
+
return { () -> bridge.std__shared_ptr_HybridRecognizerSpec_ in
|
|
121
|
+
let __cxxWrapped = self.__implementation.recognizer.getCxxWrapper()
|
|
122
|
+
return __cxxWrapped.getCxxPart()
|
|
123
|
+
}()
|
|
124
|
+
}
|
|
125
|
+
@inline(__always)
|
|
126
|
+
set {
|
|
127
|
+
self.__implementation.recognizer = { () -> HybridRecognizerSpec in
|
|
128
|
+
let __unsafePointer = bridge.get_std__shared_ptr_HybridRecognizerSpec_(newValue)
|
|
129
|
+
let __instance = HybridRecognizerSpec_cxx.fromUnsafe(__unsafePointer)
|
|
130
|
+
return __instance.getHybridRecognizerSpec()
|
|
131
|
+
}()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Methods
|
|
136
|
+
|
|
137
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRecognizerSpec.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridRecognizerSpec``
|
|
12
|
+
public protocol HybridRecognizerSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
var onReadyForSpeech: (() -> Void)? { get set }
|
|
15
|
+
var onRecordingStopped: (() -> Void)? { get set }
|
|
16
|
+
var onResult: ((_ resultBatches: [String]) -> Void)? { get set }
|
|
17
|
+
var onAutoFinishProgress: ((_ timeLeftMs: Double) -> Void)? { get set }
|
|
18
|
+
var onError: ((_ message: String) -> Void)? { get set }
|
|
19
|
+
var onPermissionDenied: (() -> Void)? { get set }
|
|
20
|
+
|
|
21
|
+
// Methods
|
|
22
|
+
func startListening(params: SpeechToTextParams) throws -> Void
|
|
23
|
+
func stopListening() throws -> Void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public extension HybridRecognizerSpec_protocol {
|
|
27
|
+
/// Default implementation of ``HybridObject.toString``
|
|
28
|
+
func toString() -> String {
|
|
29
|
+
return "[HybridObject Recognizer]"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// See ``HybridRecognizerSpec``
|
|
34
|
+
open class HybridRecognizerSpec_base {
|
|
35
|
+
private weak var cxxWrapper: HybridRecognizerSpec_cxx? = nil
|
|
36
|
+
public init() { }
|
|
37
|
+
public func getCxxWrapper() -> HybridRecognizerSpec_cxx {
|
|
38
|
+
#if DEBUG
|
|
39
|
+
guard self is HybridRecognizerSpec else {
|
|
40
|
+
fatalError("`self` is not a `HybridRecognizerSpec`! Did you accidentally inherit from `HybridRecognizerSpec_base` instead of `HybridRecognizerSpec`?")
|
|
41
|
+
}
|
|
42
|
+
#endif
|
|
43
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
44
|
+
return cxxWrapper
|
|
45
|
+
} else {
|
|
46
|
+
let cxxWrapper = HybridRecognizerSpec_cxx(self as! HybridRecognizerSpec)
|
|
47
|
+
self.cxxWrapper = cxxWrapper
|
|
48
|
+
return cxxWrapper
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A Swift base-protocol representing the Recognizer HybridObject.
|
|
55
|
+
* Implement this protocol to create Swift-based instances of Recognizer.
|
|
56
|
+
* ```swift
|
|
57
|
+
* class HybridRecognizer : HybridRecognizerSpec {
|
|
58
|
+
* // ...
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
public typealias HybridRecognizerSpec = HybridRecognizerSpec_protocol & HybridRecognizerSpec_base
|