@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,337 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRecognizerSpec_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 HybridRecognizerSpec 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 HybridRecognizerSpec_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 `HybridRecognizerSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridRecognizerSpec
|
|
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_HybridRecognizerSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridRecognizerSpec_cxx` that wraps the given `HybridRecognizerSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridRecognizerSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridRecognizerSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridRecognizerSpec() -> any HybridRecognizerSpec {
|
|
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 `HybridRecognizerSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridRecognizerSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridRecognizerSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridRecognizerSpec_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<HybridRecognizerSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridRecognizerSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridRecognizerSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridRecognizerSpec_(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 onReadyForSpeech: bridge.std__optional_std__function_void____ {
|
|
118
|
+
@inline(__always)
|
|
119
|
+
get {
|
|
120
|
+
return { () -> bridge.std__optional_std__function_void____ in
|
|
121
|
+
if let __unwrappedValue = self.__implementation.onReadyForSpeech {
|
|
122
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
123
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
124
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
125
|
+
}())
|
|
126
|
+
} else {
|
|
127
|
+
return .init()
|
|
128
|
+
}
|
|
129
|
+
}()
|
|
130
|
+
}
|
|
131
|
+
@inline(__always)
|
|
132
|
+
set {
|
|
133
|
+
self.__implementation.onReadyForSpeech = { () -> (() -> Void)? in
|
|
134
|
+
if bridge.has_value_std__optional_std__function_void____(newValue) {
|
|
135
|
+
let __unwrapped = bridge.get_std__optional_std__function_void____(newValue)
|
|
136
|
+
return { () -> () -> Void in
|
|
137
|
+
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
|
|
138
|
+
return { () -> Void in
|
|
139
|
+
__wrappedFunction.call()
|
|
140
|
+
}
|
|
141
|
+
}()
|
|
142
|
+
} else {
|
|
143
|
+
return nil
|
|
144
|
+
}
|
|
145
|
+
}()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public final var onRecordingStopped: bridge.std__optional_std__function_void____ {
|
|
150
|
+
@inline(__always)
|
|
151
|
+
get {
|
|
152
|
+
return { () -> bridge.std__optional_std__function_void____ in
|
|
153
|
+
if let __unwrappedValue = self.__implementation.onRecordingStopped {
|
|
154
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
155
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
156
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
157
|
+
}())
|
|
158
|
+
} else {
|
|
159
|
+
return .init()
|
|
160
|
+
}
|
|
161
|
+
}()
|
|
162
|
+
}
|
|
163
|
+
@inline(__always)
|
|
164
|
+
set {
|
|
165
|
+
self.__implementation.onRecordingStopped = { () -> (() -> Void)? in
|
|
166
|
+
if bridge.has_value_std__optional_std__function_void____(newValue) {
|
|
167
|
+
let __unwrapped = bridge.get_std__optional_std__function_void____(newValue)
|
|
168
|
+
return { () -> () -> Void in
|
|
169
|
+
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
|
|
170
|
+
return { () -> Void in
|
|
171
|
+
__wrappedFunction.call()
|
|
172
|
+
}
|
|
173
|
+
}()
|
|
174
|
+
} else {
|
|
175
|
+
return nil
|
|
176
|
+
}
|
|
177
|
+
}()
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public final var onResult: bridge.std__optional_std__function_void_const_std__vector_std__string______resultBatches______ {
|
|
182
|
+
@inline(__always)
|
|
183
|
+
get {
|
|
184
|
+
return { () -> bridge.std__optional_std__function_void_const_std__vector_std__string______resultBatches______ in
|
|
185
|
+
if let __unwrappedValue = self.__implementation.onResult {
|
|
186
|
+
return bridge.create_std__optional_std__function_void_const_std__vector_std__string______resultBatches______({ () -> bridge.Func_void_std__vector_std__string_ in
|
|
187
|
+
let __closureWrapper = Func_void_std__vector_std__string_(__unwrappedValue)
|
|
188
|
+
return bridge.create_Func_void_std__vector_std__string_(__closureWrapper.toUnsafe())
|
|
189
|
+
}())
|
|
190
|
+
} else {
|
|
191
|
+
return .init()
|
|
192
|
+
}
|
|
193
|
+
}()
|
|
194
|
+
}
|
|
195
|
+
@inline(__always)
|
|
196
|
+
set {
|
|
197
|
+
self.__implementation.onResult = { () -> ((_ resultBatches: [String]) -> Void)? in
|
|
198
|
+
if bridge.has_value_std__optional_std__function_void_const_std__vector_std__string______resultBatches______(newValue) {
|
|
199
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_std__vector_std__string______resultBatches______(newValue)
|
|
200
|
+
return { () -> ([String]) -> Void in
|
|
201
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__vector_std__string_(__unwrapped)
|
|
202
|
+
return { (__resultBatches: [String]) -> Void in
|
|
203
|
+
__wrappedFunction.call({ () -> bridge.std__vector_std__string_ in
|
|
204
|
+
var __vector = bridge.create_std__vector_std__string_(__resultBatches.count)
|
|
205
|
+
for __item in __resultBatches {
|
|
206
|
+
__vector.push_back(std.string(__item))
|
|
207
|
+
}
|
|
208
|
+
return __vector
|
|
209
|
+
}())
|
|
210
|
+
}
|
|
211
|
+
}()
|
|
212
|
+
} else {
|
|
213
|
+
return nil
|
|
214
|
+
}
|
|
215
|
+
}()
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
public final var onAutoFinishProgress: bridge.std__optional_std__function_void_double____timeLeftMs______ {
|
|
220
|
+
@inline(__always)
|
|
221
|
+
get {
|
|
222
|
+
return { () -> bridge.std__optional_std__function_void_double____timeLeftMs______ in
|
|
223
|
+
if let __unwrappedValue = self.__implementation.onAutoFinishProgress {
|
|
224
|
+
return bridge.create_std__optional_std__function_void_double____timeLeftMs______({ () -> bridge.Func_void_double in
|
|
225
|
+
let __closureWrapper = Func_void_double(__unwrappedValue)
|
|
226
|
+
return bridge.create_Func_void_double(__closureWrapper.toUnsafe())
|
|
227
|
+
}())
|
|
228
|
+
} else {
|
|
229
|
+
return .init()
|
|
230
|
+
}
|
|
231
|
+
}()
|
|
232
|
+
}
|
|
233
|
+
@inline(__always)
|
|
234
|
+
set {
|
|
235
|
+
self.__implementation.onAutoFinishProgress = { () -> ((_ timeLeftMs: Double) -> Void)? in
|
|
236
|
+
if bridge.has_value_std__optional_std__function_void_double____timeLeftMs______(newValue) {
|
|
237
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_double____timeLeftMs______(newValue)
|
|
238
|
+
return { () -> (Double) -> Void in
|
|
239
|
+
let __wrappedFunction = bridge.wrap_Func_void_double(__unwrapped)
|
|
240
|
+
return { (__timeLeftMs: Double) -> Void in
|
|
241
|
+
__wrappedFunction.call(__timeLeftMs)
|
|
242
|
+
}
|
|
243
|
+
}()
|
|
244
|
+
} else {
|
|
245
|
+
return nil
|
|
246
|
+
}
|
|
247
|
+
}()
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
public final var onError: bridge.std__optional_std__function_void_const_std__string_____message______ {
|
|
252
|
+
@inline(__always)
|
|
253
|
+
get {
|
|
254
|
+
return { () -> bridge.std__optional_std__function_void_const_std__string_____message______ in
|
|
255
|
+
if let __unwrappedValue = self.__implementation.onError {
|
|
256
|
+
return bridge.create_std__optional_std__function_void_const_std__string_____message______({ () -> bridge.Func_void_std__string in
|
|
257
|
+
let __closureWrapper = Func_void_std__string(__unwrappedValue)
|
|
258
|
+
return bridge.create_Func_void_std__string(__closureWrapper.toUnsafe())
|
|
259
|
+
}())
|
|
260
|
+
} else {
|
|
261
|
+
return .init()
|
|
262
|
+
}
|
|
263
|
+
}()
|
|
264
|
+
}
|
|
265
|
+
@inline(__always)
|
|
266
|
+
set {
|
|
267
|
+
self.__implementation.onError = { () -> ((_ message: String) -> Void)? in
|
|
268
|
+
if bridge.has_value_std__optional_std__function_void_const_std__string_____message______(newValue) {
|
|
269
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_std__string_____message______(newValue)
|
|
270
|
+
return { () -> (String) -> Void in
|
|
271
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__string(__unwrapped)
|
|
272
|
+
return { (__message: String) -> Void in
|
|
273
|
+
__wrappedFunction.call(std.string(__message))
|
|
274
|
+
}
|
|
275
|
+
}()
|
|
276
|
+
} else {
|
|
277
|
+
return nil
|
|
278
|
+
}
|
|
279
|
+
}()
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
public final var onPermissionDenied: bridge.std__optional_std__function_void____ {
|
|
284
|
+
@inline(__always)
|
|
285
|
+
get {
|
|
286
|
+
return { () -> bridge.std__optional_std__function_void____ in
|
|
287
|
+
if let __unwrappedValue = self.__implementation.onPermissionDenied {
|
|
288
|
+
return bridge.create_std__optional_std__function_void____({ () -> bridge.Func_void in
|
|
289
|
+
let __closureWrapper = Func_void(__unwrappedValue)
|
|
290
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
291
|
+
}())
|
|
292
|
+
} else {
|
|
293
|
+
return .init()
|
|
294
|
+
}
|
|
295
|
+
}()
|
|
296
|
+
}
|
|
297
|
+
@inline(__always)
|
|
298
|
+
set {
|
|
299
|
+
self.__implementation.onPermissionDenied = { () -> (() -> Void)? in
|
|
300
|
+
if bridge.has_value_std__optional_std__function_void____(newValue) {
|
|
301
|
+
let __unwrapped = bridge.get_std__optional_std__function_void____(newValue)
|
|
302
|
+
return { () -> () -> Void in
|
|
303
|
+
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
|
|
304
|
+
return { () -> Void in
|
|
305
|
+
__wrappedFunction.call()
|
|
306
|
+
}
|
|
307
|
+
}()
|
|
308
|
+
} else {
|
|
309
|
+
return nil
|
|
310
|
+
}
|
|
311
|
+
}()
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Methods
|
|
316
|
+
@inline(__always)
|
|
317
|
+
public final func startListening(params: SpeechToTextParams) -> bridge.Result_void_ {
|
|
318
|
+
do {
|
|
319
|
+
try self.__implementation.startListening(params: params)
|
|
320
|
+
return bridge.create_Result_void_()
|
|
321
|
+
} catch (let __error) {
|
|
322
|
+
let __exceptionPtr = __error.toCpp()
|
|
323
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
@inline(__always)
|
|
328
|
+
public final func stopListening() -> bridge.Result_void_ {
|
|
329
|
+
do {
|
|
330
|
+
try self.__implementation.stopListening()
|
|
331
|
+
return bridge.create_Result_void_()
|
|
332
|
+
} catch (let __error) {
|
|
333
|
+
let __exceptionPtr = __error.toCpp()
|
|
334
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SpeechToTextParams.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
|
+
* Represents an instance of `SpeechToTextParams`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias SpeechToTextParams = margelo.nitro.nitrospeech.SpeechToTextParams
|
|
15
|
+
|
|
16
|
+
public extension SpeechToTextParams {
|
|
17
|
+
private typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `SpeechToTextParams`.
|
|
21
|
+
*/
|
|
22
|
+
init(locale: String?, autoFinishRecognitionMs: Double?, disableRepeatingFilter: Bool?, contextualStrings: [String]?, androidMaskOffensiveWords: Bool?, androidFormattingPreferQuality: Bool?, androidUseWebSearchModel: Bool?, androidDisableBatchHandling: Bool?, iosAddPunctuation: Bool?) {
|
|
23
|
+
self.init({ () -> bridge.std__optional_std__string_ in
|
|
24
|
+
if let __unwrappedValue = locale {
|
|
25
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
26
|
+
} else {
|
|
27
|
+
return .init()
|
|
28
|
+
}
|
|
29
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
30
|
+
if let __unwrappedValue = autoFinishRecognitionMs {
|
|
31
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
32
|
+
} else {
|
|
33
|
+
return .init()
|
|
34
|
+
}
|
|
35
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
36
|
+
if let __unwrappedValue = disableRepeatingFilter {
|
|
37
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
38
|
+
} else {
|
|
39
|
+
return .init()
|
|
40
|
+
}
|
|
41
|
+
}(), { () -> bridge.std__optional_std__vector_std__string__ in
|
|
42
|
+
if let __unwrappedValue = contextualStrings {
|
|
43
|
+
return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
|
|
44
|
+
var __vector = bridge.create_std__vector_std__string_(__unwrappedValue.count)
|
|
45
|
+
for __item in __unwrappedValue {
|
|
46
|
+
__vector.push_back(std.string(__item))
|
|
47
|
+
}
|
|
48
|
+
return __vector
|
|
49
|
+
}())
|
|
50
|
+
} else {
|
|
51
|
+
return .init()
|
|
52
|
+
}
|
|
53
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
54
|
+
if let __unwrappedValue = androidMaskOffensiveWords {
|
|
55
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
56
|
+
} else {
|
|
57
|
+
return .init()
|
|
58
|
+
}
|
|
59
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
60
|
+
if let __unwrappedValue = androidFormattingPreferQuality {
|
|
61
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
62
|
+
} else {
|
|
63
|
+
return .init()
|
|
64
|
+
}
|
|
65
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
66
|
+
if let __unwrappedValue = androidUseWebSearchModel {
|
|
67
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
68
|
+
} else {
|
|
69
|
+
return .init()
|
|
70
|
+
}
|
|
71
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
72
|
+
if let __unwrappedValue = androidDisableBatchHandling {
|
|
73
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
74
|
+
} else {
|
|
75
|
+
return .init()
|
|
76
|
+
}
|
|
77
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
78
|
+
if let __unwrappedValue = iosAddPunctuation {
|
|
79
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
80
|
+
} else {
|
|
81
|
+
return .init()
|
|
82
|
+
}
|
|
83
|
+
}())
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var locale: String? {
|
|
87
|
+
@inline(__always)
|
|
88
|
+
get {
|
|
89
|
+
return { () -> String? in
|
|
90
|
+
if bridge.has_value_std__optional_std__string_(self.__locale) {
|
|
91
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__locale)
|
|
92
|
+
return String(__unwrapped)
|
|
93
|
+
} else {
|
|
94
|
+
return nil
|
|
95
|
+
}
|
|
96
|
+
}()
|
|
97
|
+
}
|
|
98
|
+
@inline(__always)
|
|
99
|
+
set {
|
|
100
|
+
self.__locale = { () -> bridge.std__optional_std__string_ in
|
|
101
|
+
if let __unwrappedValue = newValue {
|
|
102
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
103
|
+
} else {
|
|
104
|
+
return .init()
|
|
105
|
+
}
|
|
106
|
+
}()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
var autoFinishRecognitionMs: Double? {
|
|
111
|
+
@inline(__always)
|
|
112
|
+
get {
|
|
113
|
+
return self.__autoFinishRecognitionMs.value
|
|
114
|
+
}
|
|
115
|
+
@inline(__always)
|
|
116
|
+
set {
|
|
117
|
+
self.__autoFinishRecognitionMs = { () -> bridge.std__optional_double_ in
|
|
118
|
+
if let __unwrappedValue = newValue {
|
|
119
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
120
|
+
} else {
|
|
121
|
+
return .init()
|
|
122
|
+
}
|
|
123
|
+
}()
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
var disableRepeatingFilter: Bool? {
|
|
128
|
+
@inline(__always)
|
|
129
|
+
get {
|
|
130
|
+
return { () -> Bool? in
|
|
131
|
+
if bridge.has_value_std__optional_bool_(self.__disableRepeatingFilter) {
|
|
132
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__disableRepeatingFilter)
|
|
133
|
+
return __unwrapped
|
|
134
|
+
} else {
|
|
135
|
+
return nil
|
|
136
|
+
}
|
|
137
|
+
}()
|
|
138
|
+
}
|
|
139
|
+
@inline(__always)
|
|
140
|
+
set {
|
|
141
|
+
self.__disableRepeatingFilter = { () -> bridge.std__optional_bool_ in
|
|
142
|
+
if let __unwrappedValue = newValue {
|
|
143
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
144
|
+
} else {
|
|
145
|
+
return .init()
|
|
146
|
+
}
|
|
147
|
+
}()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var contextualStrings: [String]? {
|
|
152
|
+
@inline(__always)
|
|
153
|
+
get {
|
|
154
|
+
return { () -> [String]? in
|
|
155
|
+
if bridge.has_value_std__optional_std__vector_std__string__(self.__contextualStrings) {
|
|
156
|
+
let __unwrapped = bridge.get_std__optional_std__vector_std__string__(self.__contextualStrings)
|
|
157
|
+
return __unwrapped.map({ __item in String(__item) })
|
|
158
|
+
} else {
|
|
159
|
+
return nil
|
|
160
|
+
}
|
|
161
|
+
}()
|
|
162
|
+
}
|
|
163
|
+
@inline(__always)
|
|
164
|
+
set {
|
|
165
|
+
self.__contextualStrings = { () -> bridge.std__optional_std__vector_std__string__ in
|
|
166
|
+
if let __unwrappedValue = newValue {
|
|
167
|
+
return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
|
|
168
|
+
var __vector = bridge.create_std__vector_std__string_(__unwrappedValue.count)
|
|
169
|
+
for __item in __unwrappedValue {
|
|
170
|
+
__vector.push_back(std.string(__item))
|
|
171
|
+
}
|
|
172
|
+
return __vector
|
|
173
|
+
}())
|
|
174
|
+
} else {
|
|
175
|
+
return .init()
|
|
176
|
+
}
|
|
177
|
+
}()
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var androidMaskOffensiveWords: Bool? {
|
|
182
|
+
@inline(__always)
|
|
183
|
+
get {
|
|
184
|
+
return { () -> Bool? in
|
|
185
|
+
if bridge.has_value_std__optional_bool_(self.__androidMaskOffensiveWords) {
|
|
186
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__androidMaskOffensiveWords)
|
|
187
|
+
return __unwrapped
|
|
188
|
+
} else {
|
|
189
|
+
return nil
|
|
190
|
+
}
|
|
191
|
+
}()
|
|
192
|
+
}
|
|
193
|
+
@inline(__always)
|
|
194
|
+
set {
|
|
195
|
+
self.__androidMaskOffensiveWords = { () -> bridge.std__optional_bool_ in
|
|
196
|
+
if let __unwrappedValue = newValue {
|
|
197
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
198
|
+
} else {
|
|
199
|
+
return .init()
|
|
200
|
+
}
|
|
201
|
+
}()
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
var androidFormattingPreferQuality: Bool? {
|
|
206
|
+
@inline(__always)
|
|
207
|
+
get {
|
|
208
|
+
return { () -> Bool? in
|
|
209
|
+
if bridge.has_value_std__optional_bool_(self.__androidFormattingPreferQuality) {
|
|
210
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__androidFormattingPreferQuality)
|
|
211
|
+
return __unwrapped
|
|
212
|
+
} else {
|
|
213
|
+
return nil
|
|
214
|
+
}
|
|
215
|
+
}()
|
|
216
|
+
}
|
|
217
|
+
@inline(__always)
|
|
218
|
+
set {
|
|
219
|
+
self.__androidFormattingPreferQuality = { () -> bridge.std__optional_bool_ in
|
|
220
|
+
if let __unwrappedValue = newValue {
|
|
221
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
222
|
+
} else {
|
|
223
|
+
return .init()
|
|
224
|
+
}
|
|
225
|
+
}()
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
var androidUseWebSearchModel: Bool? {
|
|
230
|
+
@inline(__always)
|
|
231
|
+
get {
|
|
232
|
+
return { () -> Bool? in
|
|
233
|
+
if bridge.has_value_std__optional_bool_(self.__androidUseWebSearchModel) {
|
|
234
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__androidUseWebSearchModel)
|
|
235
|
+
return __unwrapped
|
|
236
|
+
} else {
|
|
237
|
+
return nil
|
|
238
|
+
}
|
|
239
|
+
}()
|
|
240
|
+
}
|
|
241
|
+
@inline(__always)
|
|
242
|
+
set {
|
|
243
|
+
self.__androidUseWebSearchModel = { () -> bridge.std__optional_bool_ in
|
|
244
|
+
if let __unwrappedValue = newValue {
|
|
245
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
246
|
+
} else {
|
|
247
|
+
return .init()
|
|
248
|
+
}
|
|
249
|
+
}()
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
var androidDisableBatchHandling: Bool? {
|
|
254
|
+
@inline(__always)
|
|
255
|
+
get {
|
|
256
|
+
return { () -> Bool? in
|
|
257
|
+
if bridge.has_value_std__optional_bool_(self.__androidDisableBatchHandling) {
|
|
258
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__androidDisableBatchHandling)
|
|
259
|
+
return __unwrapped
|
|
260
|
+
} else {
|
|
261
|
+
return nil
|
|
262
|
+
}
|
|
263
|
+
}()
|
|
264
|
+
}
|
|
265
|
+
@inline(__always)
|
|
266
|
+
set {
|
|
267
|
+
self.__androidDisableBatchHandling = { () -> bridge.std__optional_bool_ in
|
|
268
|
+
if let __unwrappedValue = newValue {
|
|
269
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
270
|
+
} else {
|
|
271
|
+
return .init()
|
|
272
|
+
}
|
|
273
|
+
}()
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
var iosAddPunctuation: Bool? {
|
|
278
|
+
@inline(__always)
|
|
279
|
+
get {
|
|
280
|
+
return { () -> Bool? in
|
|
281
|
+
if bridge.has_value_std__optional_bool_(self.__iosAddPunctuation) {
|
|
282
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__iosAddPunctuation)
|
|
283
|
+
return __unwrapped
|
|
284
|
+
} else {
|
|
285
|
+
return nil
|
|
286
|
+
}
|
|
287
|
+
}()
|
|
288
|
+
}
|
|
289
|
+
@inline(__always)
|
|
290
|
+
set {
|
|
291
|
+
self.__iosAddPunctuation = { () -> bridge.std__optional_bool_ in
|
|
292
|
+
if let __unwrappedValue = newValue {
|
|
293
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
294
|
+
} else {
|
|
295
|
+
return .init()
|
|
296
|
+
}
|
|
297
|
+
}()
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSpeechSpec.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 "HybridNitroSpeechSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitrospeech {
|
|
11
|
+
|
|
12
|
+
void HybridNitroSpeechSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("recognizer", &HybridNitroSpeechSpec::getRecognizer);
|
|
18
|
+
prototype.registerHybridSetter("recognizer", &HybridNitroSpeechSpec::setRecognizer);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace margelo::nitro::nitrospeech
|