@gmessier/nitro-speech 0.3.3 → 0.4.0
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/LICENSE +21 -0
- package/README.md +165 -148
- package/android/build.gradle +0 -1
- package/android/src/main/cpp/cpp-adapter.cpp +5 -1
- package/android/src/main/java/com/margelo/nitro/nitrospeech/HybridNitroSpeech.kt +2 -0
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/AutoStopper.kt +80 -16
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/HybridRecognizer.kt +93 -20
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/RecognitionListenerSession.kt +27 -15
- package/ios/{BufferUtil.swift → Audio/AudioBufferConverter.swift} +3 -34
- package/ios/Audio/AudioLevelTracker.swift +66 -0
- package/ios/Coordinator.swift +105 -0
- package/ios/Engines/AnalyzerEngine.swift +241 -0
- package/ios/Engines/DictationRuntime.swift +67 -0
- package/ios/Engines/RecognizerEngine.swift +312 -0
- package/ios/Engines/SFSpeechEngine.swift +119 -0
- package/ios/Engines/SpeechRuntime.swift +58 -0
- package/ios/Engines/TranscriberRuntimeProtocol.swift +21 -0
- package/ios/HybridNitroSpeech.swift +1 -10
- package/ios/HybridRecognizer.swift +135 -192
- package/ios/LocaleManager.swift +73 -0
- package/ios/{AppStateObserver.swift → Shared/AppStateObserver.swift} +1 -2
- package/ios/Shared/AutoStopper.swift +147 -0
- package/ios/Shared/HapticImpact.swift +24 -0
- package/ios/Shared/Log.swift +41 -0
- package/ios/Shared/Permissions.swift +59 -0
- package/ios/Shared/Utils.swift +58 -0
- package/lib/NitroSpeech.d.ts +2 -0
- package/lib/NitroSpeech.js +2 -0
- package/lib/Recognizer/RecognizerRef.d.ts +5 -0
- package/lib/Recognizer/RecognizerRef.js +13 -0
- package/lib/Recognizer/SpeechRecognizer.d.ts +8 -0
- package/lib/Recognizer/SpeechRecognizer.js +9 -0
- package/lib/Recognizer/methods.d.ts +8 -0
- package/lib/Recognizer/methods.js +29 -0
- package/lib/Recognizer/types.d.ts +6 -0
- package/lib/Recognizer/types.js +1 -0
- package/lib/Recognizer/useRecognizer.d.ts +16 -0
- package/lib/Recognizer/useRecognizer.js +71 -0
- package/lib/Recognizer/useVoiceInputVolume.d.ts +25 -0
- package/lib/Recognizer/useVoiceInputVolume.js +52 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +6 -0
- package/lib/specs/NitroSpeech.nitro.d.ts +8 -0
- package/lib/specs/NitroSpeech.nitro.js +1 -0
- package/lib/specs/Recognizer.nitro.d.ts +95 -0
- package/lib/specs/Recognizer.nitro.js +1 -0
- package/lib/specs/SpeechRecognitionConfig.d.ts +162 -0
- package/lib/specs/SpeechRecognitionConfig.js +1 -0
- package/lib/specs/VolumeChangeEvent.d.ts +31 -0
- package/lib/specs/VolumeChangeEvent.js +1 -0
- package/nitro.json +0 -4
- package/nitrogen/generated/android/NitroSpeech+autolinking.cmake +2 -2
- package/nitrogen/generated/android/NitroSpeechOnLoad.cpp +4 -2
- package/nitrogen/generated/android/c++/JFunc_void_VolumeChangeEvent.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp +14 -14
- package/nitrogen/generated/android/c++/JHybridRecognizerSpec.cpp +68 -19
- package/nitrogen/generated/android/c++/JHybridRecognizerSpec.hpp +7 -4
- package/nitrogen/generated/android/c++/JIosPreset.hpp +58 -0
- package/nitrogen/generated/android/c++/JMutableSpeechRecognitionConfig.hpp +79 -0
- package/nitrogen/generated/android/c++/{JSpeechToTextParams.hpp → JSpeechRecognitionConfig.hpp} +48 -30
- package/nitrogen/generated/android/c++/JVolumeChangeEvent.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_VolumeChangeEvent.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridRecognizerSpec.kt +18 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/IosPreset.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/MutableSpeechRecognitionConfig.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/SpeechRecognitionConfig.kt +121 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/VolumeChangeEvent.kt +61 -0
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.cpp +46 -30
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.hpp +203 -70
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Umbrella.hpp +13 -3
- package/nitrogen/generated/ios/c++/HybridRecognizerSpecSwift.hpp +41 -9
- package/nitrogen/generated/ios/swift/Func_void_VolumeChangeEvent.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridRecognizerSpec.swift +6 -3
- package/nitrogen/generated/ios/swift/HybridRecognizerSpec_cxx.swift +66 -18
- package/nitrogen/generated/ios/swift/IosPreset.swift +40 -0
- package/nitrogen/generated/ios/swift/MutableSpeechRecognitionConfig.swift +118 -0
- package/nitrogen/generated/ios/swift/{SpeechToTextParams.swift → SpeechRecognitionConfig.swift} +108 -43
- package/nitrogen/generated/ios/swift/VolumeChangeEvent.swift +52 -0
- package/nitrogen/generated/shared/c++/HybridRecognizerSpec.cpp +4 -1
- package/nitrogen/generated/shared/c++/HybridRecognizerSpec.hpp +17 -7
- package/nitrogen/generated/shared/c++/IosPreset.hpp +76 -0
- package/nitrogen/generated/shared/c++/MutableSpeechRecognitionConfig.hpp +105 -0
- package/nitrogen/generated/shared/c++/{SpeechToTextParams.hpp → SpeechRecognitionConfig.hpp} +39 -20
- package/nitrogen/generated/shared/c++/VolumeChangeEvent.hpp +91 -0
- package/package.json +15 -16
- package/src/NitroSpeech.ts +5 -0
- package/src/Recognizer/RecognizerRef.ts +23 -0
- package/src/Recognizer/SpeechRecognizer.ts +10 -0
- package/src/Recognizer/methods.ts +40 -0
- package/src/Recognizer/types.ts +33 -0
- package/src/Recognizer/useRecognizer.ts +85 -0
- package/src/Recognizer/useVoiceInputVolume.ts +65 -0
- package/src/index.ts +6 -182
- package/src/specs/NitroSpeech.nitro.ts +2 -163
- package/src/specs/Recognizer.nitro.ts +110 -0
- package/src/specs/SpeechRecognitionConfig.ts +167 -0
- package/src/specs/VolumeChangeEvent.ts +31 -0
- package/android/proguard-rules.pro +0 -1
- package/ios/AnylyzerTranscriber.swift +0 -331
- package/ios/AutoStopper.swift +0 -69
- package/ios/HapticImpact.swift +0 -32
- package/ios/LegacySpeechRecognizer.swift +0 -161
- package/lib/commonjs/index.js +0 -145
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/commonjs/specs/NitroSpeech.nitro.js +0 -6
- package/lib/commonjs/specs/NitroSpeech.nitro.js.map +0 -1
- package/lib/module/index.js +0 -138
- package/lib/module/index.js.map +0 -1
- package/lib/module/package.json +0 -1
- package/lib/module/specs/NitroSpeech.nitro.js +0 -4
- package/lib/module/specs/NitroSpeech.nitro.js.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/typescript/index.d.ts +0 -50
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/specs/NitroSpeech.nitro.d.ts +0 -162
- package/lib/typescript/specs/NitroSpeech.nitro.d.ts.map +0 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/SpeechToTextParams.kt +0 -68
|
@@ -12,17 +12,27 @@
|
|
|
12
12
|
// Forward declaration of `HybridRecognizerSpec_cxx` to properly resolve imports.
|
|
13
13
|
namespace NitroSpeech { class HybridRecognizerSpec_cxx; }
|
|
14
14
|
|
|
15
|
-
// Forward declaration of `
|
|
16
|
-
namespace margelo::nitro::nitrospeech { struct
|
|
15
|
+
// Forward declaration of `VolumeChangeEvent` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrospeech { struct VolumeChangeEvent; }
|
|
17
|
+
// Forward declaration of `SpeechRecognitionConfig` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitrospeech { struct SpeechRecognitionConfig; }
|
|
17
19
|
// Forward declaration of `HapticFeedbackStyle` to properly resolve imports.
|
|
18
20
|
namespace margelo::nitro::nitrospeech { enum class HapticFeedbackStyle; }
|
|
21
|
+
// Forward declaration of `IosPreset` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitrospeech { enum class IosPreset; }
|
|
23
|
+
// Forward declaration of `MutableSpeechRecognitionConfig` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::nitrospeech { struct MutableSpeechRecognitionConfig; }
|
|
19
25
|
|
|
20
26
|
#include <functional>
|
|
21
27
|
#include <optional>
|
|
22
28
|
#include <string>
|
|
23
29
|
#include <vector>
|
|
24
|
-
#include "
|
|
30
|
+
#include "VolumeChangeEvent.hpp"
|
|
31
|
+
#include <NitroModules/Promise.hpp>
|
|
32
|
+
#include "SpeechRecognitionConfig.hpp"
|
|
25
33
|
#include "HapticFeedbackStyle.hpp"
|
|
34
|
+
#include "IosPreset.hpp"
|
|
35
|
+
#include "MutableSpeechRecognitionConfig.hpp"
|
|
26
36
|
|
|
27
37
|
#include "NitroSpeech-Swift-Cxx-Umbrella.hpp"
|
|
28
38
|
|
|
@@ -112,18 +122,26 @@ namespace margelo::nitro::nitrospeech {
|
|
|
112
122
|
inline void setOnPermissionDenied(const std::optional<std::function<void()>>& onPermissionDenied) noexcept override {
|
|
113
123
|
_swiftPart.setOnPermissionDenied(onPermissionDenied);
|
|
114
124
|
}
|
|
115
|
-
inline std::optional<std::function<void(
|
|
125
|
+
inline std::optional<std::function<void(const VolumeChangeEvent& /* event */)>> getOnVolumeChange() noexcept override {
|
|
116
126
|
auto __result = _swiftPart.getOnVolumeChange();
|
|
117
127
|
return __result;
|
|
118
128
|
}
|
|
119
|
-
inline void setOnVolumeChange(const std::optional<std::function<void(
|
|
129
|
+
inline void setOnVolumeChange(const std::optional<std::function<void(const VolumeChangeEvent& /* event */)>>& onVolumeChange) noexcept override {
|
|
120
130
|
_swiftPart.setOnVolumeChange(onVolumeChange);
|
|
121
131
|
}
|
|
122
132
|
|
|
123
133
|
public:
|
|
124
134
|
// Methods
|
|
125
|
-
inline void
|
|
126
|
-
auto __result = _swiftPart.
|
|
135
|
+
inline std::shared_ptr<Promise<void>> prewarm(const std::optional<SpeechRecognitionConfig>& defaultParams) override {
|
|
136
|
+
auto __result = _swiftPart.prewarm(defaultParams);
|
|
137
|
+
if (__result.hasError()) [[unlikely]] {
|
|
138
|
+
std::rethrow_exception(__result.error());
|
|
139
|
+
}
|
|
140
|
+
auto __value = std::move(__result.value());
|
|
141
|
+
return __value;
|
|
142
|
+
}
|
|
143
|
+
inline void startListening(const std::optional<SpeechRecognitionConfig>& params) override {
|
|
144
|
+
auto __result = _swiftPart.startListening(params);
|
|
127
145
|
if (__result.hasError()) [[unlikely]] {
|
|
128
146
|
std::rethrow_exception(__result.error());
|
|
129
147
|
}
|
|
@@ -134,14 +152,20 @@ namespace margelo::nitro::nitrospeech {
|
|
|
134
152
|
std::rethrow_exception(__result.error());
|
|
135
153
|
}
|
|
136
154
|
}
|
|
155
|
+
inline void resetAutoFinishTime() override {
|
|
156
|
+
auto __result = _swiftPart.resetAutoFinishTime();
|
|
157
|
+
if (__result.hasError()) [[unlikely]] {
|
|
158
|
+
std::rethrow_exception(__result.error());
|
|
159
|
+
}
|
|
160
|
+
}
|
|
137
161
|
inline void addAutoFinishTime(std::optional<double> additionalTimeMs) override {
|
|
138
162
|
auto __result = _swiftPart.addAutoFinishTime(additionalTimeMs);
|
|
139
163
|
if (__result.hasError()) [[unlikely]] {
|
|
140
164
|
std::rethrow_exception(__result.error());
|
|
141
165
|
}
|
|
142
166
|
}
|
|
143
|
-
inline void
|
|
144
|
-
auto __result = _swiftPart.
|
|
167
|
+
inline void updateConfig(const std::optional<MutableSpeechRecognitionConfig>& newConfig, std::optional<bool> resetAutoFinishTime) override {
|
|
168
|
+
auto __result = _swiftPart.updateConfig(newConfig, resetAutoFinishTime);
|
|
145
169
|
if (__result.hasError()) [[unlikely]] {
|
|
146
170
|
std::rethrow_exception(__result.error());
|
|
147
171
|
}
|
|
@@ -154,6 +178,14 @@ namespace margelo::nitro::nitrospeech {
|
|
|
154
178
|
auto __value = std::move(__result.value());
|
|
155
179
|
return __value;
|
|
156
180
|
}
|
|
181
|
+
inline std::vector<std::string> getSupportedLocalesIOS() override {
|
|
182
|
+
auto __result = _swiftPart.getSupportedLocalesIOS();
|
|
183
|
+
if (__result.hasError()) [[unlikely]] {
|
|
184
|
+
std::rethrow_exception(__result.error());
|
|
185
|
+
}
|
|
186
|
+
auto __value = std::move(__result.value());
|
|
187
|
+
return __value;
|
|
188
|
+
}
|
|
157
189
|
|
|
158
190
|
private:
|
|
159
191
|
NitroSpeech::HybridRecognizerSpec_cxx _swiftPart;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_VolumeChangeEvent.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ event: VolumeChangeEvent) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_VolumeChangeEvent {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ event: VolumeChangeEvent) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ event: VolumeChangeEvent) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(event: VolumeChangeEvent) -> Void {
|
|
25
|
+
self.closure(event)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_VolumeChangeEvent`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_VolumeChangeEvent>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_VolumeChangeEvent {
|
|
44
|
+
return Unmanaged<Func_void_VolumeChangeEvent>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__exception_ptr {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ error: Error) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
25
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
44
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -16,14 +16,17 @@ public protocol HybridRecognizerSpec_protocol: HybridObject {
|
|
|
16
16
|
var onAutoFinishProgress: ((_ timeLeftMs: Double) -> Void)? { get set }
|
|
17
17
|
var onError: ((_ message: String) -> Void)? { get set }
|
|
18
18
|
var onPermissionDenied: (() -> Void)? { get set }
|
|
19
|
-
var onVolumeChange: ((_
|
|
19
|
+
var onVolumeChange: ((_ event: VolumeChangeEvent) -> Void)? { get set }
|
|
20
20
|
|
|
21
21
|
// Methods
|
|
22
|
-
func
|
|
22
|
+
func prewarm(defaultParams: SpeechRecognitionConfig?) throws -> Promise<Void>
|
|
23
|
+
func startListening(params: SpeechRecognitionConfig?) throws -> Void
|
|
23
24
|
func stopListening() throws -> Void
|
|
25
|
+
func resetAutoFinishTime() throws -> Void
|
|
24
26
|
func addAutoFinishTime(additionalTimeMs: Double?) throws -> Void
|
|
25
|
-
func
|
|
27
|
+
func updateConfig(newConfig: MutableSpeechRecognitionConfig?, resetAutoFinishTime: Bool?) throws -> Void
|
|
26
28
|
func getIsActive() throws -> Bool
|
|
29
|
+
func getSupportedLocalesIOS() throws -> [String]
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
public extension HybridRecognizerSpec_protocol {
|
|
@@ -319,14 +319,14 @@ open class HybridRecognizerSpec_cxx {
|
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
public final var onVolumeChange: bridge.
|
|
322
|
+
public final var onVolumeChange: bridge.std__optional_std__function_void_const_VolumeChangeEvent_____event______ {
|
|
323
323
|
@inline(__always)
|
|
324
324
|
get {
|
|
325
|
-
return { () -> bridge.
|
|
325
|
+
return { () -> bridge.std__optional_std__function_void_const_VolumeChangeEvent_____event______ in
|
|
326
326
|
if let __unwrappedValue = self.__implementation.onVolumeChange {
|
|
327
|
-
return bridge.
|
|
328
|
-
let __closureWrapper =
|
|
329
|
-
return bridge.
|
|
327
|
+
return bridge.create_std__optional_std__function_void_const_VolumeChangeEvent_____event______({ () -> bridge.Func_void_VolumeChangeEvent in
|
|
328
|
+
let __closureWrapper = Func_void_VolumeChangeEvent(__unwrappedValue)
|
|
329
|
+
return bridge.create_Func_void_VolumeChangeEvent(__closureWrapper.toUnsafe())
|
|
330
330
|
}())
|
|
331
331
|
} else {
|
|
332
332
|
return .init()
|
|
@@ -335,13 +335,13 @@ open class HybridRecognizerSpec_cxx {
|
|
|
335
335
|
}
|
|
336
336
|
@inline(__always)
|
|
337
337
|
set {
|
|
338
|
-
self.__implementation.onVolumeChange = { () -> ((_
|
|
339
|
-
if bridge.
|
|
340
|
-
let __unwrapped = bridge.
|
|
341
|
-
return { () -> (
|
|
342
|
-
let __wrappedFunction = bridge.
|
|
343
|
-
return { (
|
|
344
|
-
__wrappedFunction.call(
|
|
338
|
+
self.__implementation.onVolumeChange = { () -> ((_ event: VolumeChangeEvent) -> Void)? in
|
|
339
|
+
if bridge.has_value_std__optional_std__function_void_const_VolumeChangeEvent_____event______(newValue) {
|
|
340
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_VolumeChangeEvent_____event______(newValue)
|
|
341
|
+
return { () -> (VolumeChangeEvent) -> Void in
|
|
342
|
+
let __wrappedFunction = bridge.wrap_Func_void_VolumeChangeEvent(__unwrapped)
|
|
343
|
+
return { (__event: VolumeChangeEvent) -> Void in
|
|
344
|
+
__wrappedFunction.call(__event)
|
|
345
345
|
}
|
|
346
346
|
}()
|
|
347
347
|
} else {
|
|
@@ -353,9 +353,28 @@ open class HybridRecognizerSpec_cxx {
|
|
|
353
353
|
|
|
354
354
|
// Methods
|
|
355
355
|
@inline(__always)
|
|
356
|
-
public final func
|
|
356
|
+
public final func prewarm(defaultParams: bridge.std__optional_SpeechRecognitionConfig_) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
357
357
|
do {
|
|
358
|
-
try self.__implementation.
|
|
358
|
+
let __result = try self.__implementation.prewarm(defaultParams: defaultParams.value)
|
|
359
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
360
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
361
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
362
|
+
__result
|
|
363
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
364
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
365
|
+
return __promise
|
|
366
|
+
}()
|
|
367
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
368
|
+
} catch (let __error) {
|
|
369
|
+
let __exceptionPtr = __error.toCpp()
|
|
370
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
@inline(__always)
|
|
375
|
+
public final func startListening(params: bridge.std__optional_SpeechRecognitionConfig_) -> bridge.Result_void_ {
|
|
376
|
+
do {
|
|
377
|
+
try self.__implementation.startListening(params: params.value)
|
|
359
378
|
return bridge.create_Result_void_()
|
|
360
379
|
} catch (let __error) {
|
|
361
380
|
let __exceptionPtr = __error.toCpp()
|
|
@@ -374,6 +393,17 @@ open class HybridRecognizerSpec_cxx {
|
|
|
374
393
|
}
|
|
375
394
|
}
|
|
376
395
|
|
|
396
|
+
@inline(__always)
|
|
397
|
+
public final func resetAutoFinishTime() -> bridge.Result_void_ {
|
|
398
|
+
do {
|
|
399
|
+
try self.__implementation.resetAutoFinishTime()
|
|
400
|
+
return bridge.create_Result_void_()
|
|
401
|
+
} catch (let __error) {
|
|
402
|
+
let __exceptionPtr = __error.toCpp()
|
|
403
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
377
407
|
@inline(__always)
|
|
378
408
|
public final func addAutoFinishTime(additionalTimeMs: bridge.std__optional_double_) -> bridge.Result_void_ {
|
|
379
409
|
do {
|
|
@@ -393,11 +423,11 @@ open class HybridRecognizerSpec_cxx {
|
|
|
393
423
|
}
|
|
394
424
|
|
|
395
425
|
@inline(__always)
|
|
396
|
-
public final func
|
|
426
|
+
public final func updateConfig(newConfig: bridge.std__optional_MutableSpeechRecognitionConfig_, resetAutoFinishTime: bridge.std__optional_bool_) -> bridge.Result_void_ {
|
|
397
427
|
do {
|
|
398
|
-
try self.__implementation.
|
|
399
|
-
if bridge.has_value_std__optional_bool_(
|
|
400
|
-
let __unwrapped = bridge.get_std__optional_bool_(
|
|
428
|
+
try self.__implementation.updateConfig(newConfig: newConfig.value, resetAutoFinishTime: { () -> Bool? in
|
|
429
|
+
if bridge.has_value_std__optional_bool_(resetAutoFinishTime) {
|
|
430
|
+
let __unwrapped = bridge.get_std__optional_bool_(resetAutoFinishTime)
|
|
401
431
|
return __unwrapped
|
|
402
432
|
} else {
|
|
403
433
|
return nil
|
|
@@ -421,4 +451,22 @@ open class HybridRecognizerSpec_cxx {
|
|
|
421
451
|
return bridge.create_Result_bool_(__exceptionPtr)
|
|
422
452
|
}
|
|
423
453
|
}
|
|
454
|
+
|
|
455
|
+
@inline(__always)
|
|
456
|
+
public final func getSupportedLocalesIOS() -> bridge.Result_std__vector_std__string__ {
|
|
457
|
+
do {
|
|
458
|
+
let __result = try self.__implementation.getSupportedLocalesIOS()
|
|
459
|
+
let __resultCpp = { () -> bridge.std__vector_std__string_ in
|
|
460
|
+
var __vector = bridge.create_std__vector_std__string_(__result.count)
|
|
461
|
+
for __item in __result {
|
|
462
|
+
__vector.push_back(std.string(__item))
|
|
463
|
+
}
|
|
464
|
+
return __vector
|
|
465
|
+
}()
|
|
466
|
+
return bridge.create_Result_std__vector_std__string__(__resultCpp)
|
|
467
|
+
} catch (let __error) {
|
|
468
|
+
let __exceptionPtr = __error.toCpp()
|
|
469
|
+
return bridge.create_Result_std__vector_std__string__(__exceptionPtr)
|
|
470
|
+
}
|
|
471
|
+
}
|
|
424
472
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IosPreset.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `IosPreset`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias IosPreset = margelo.nitro.nitrospeech.IosPreset
|
|
12
|
+
|
|
13
|
+
public extension IosPreset {
|
|
14
|
+
/**
|
|
15
|
+
* Get a IosPreset for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "shortform":
|
|
21
|
+
self = .shortform
|
|
22
|
+
case "general":
|
|
23
|
+
self = .general
|
|
24
|
+
default:
|
|
25
|
+
return nil
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the String value this IosPreset represents.
|
|
31
|
+
*/
|
|
32
|
+
var stringValue: String {
|
|
33
|
+
switch self {
|
|
34
|
+
case .shortform:
|
|
35
|
+
return "shortform"
|
|
36
|
+
case .general:
|
|
37
|
+
return "general"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MutableSpeechRecognitionConfig.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `MutableSpeechRecognitionConfig`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias MutableSpeechRecognitionConfig = margelo.nitro.nitrospeech.MutableSpeechRecognitionConfig
|
|
14
|
+
|
|
15
|
+
public extension MutableSpeechRecognitionConfig {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `MutableSpeechRecognitionConfig`.
|
|
20
|
+
*/
|
|
21
|
+
init(autoFinishRecognitionMs: Double?, autoFinishProgressIntervalMs: Double?, resetAutoFinishVoiceSensitivity: Double?, disableRepeatingFilter: Bool?, startHapticFeedbackStyle: HapticFeedbackStyle?, stopHapticFeedbackStyle: HapticFeedbackStyle?) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_double_ in
|
|
23
|
+
if let __unwrappedValue = autoFinishRecognitionMs {
|
|
24
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
29
|
+
if let __unwrappedValue = autoFinishProgressIntervalMs {
|
|
30
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
35
|
+
if let __unwrappedValue = resetAutoFinishVoiceSensitivity {
|
|
36
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
41
|
+
if let __unwrappedValue = disableRepeatingFilter {
|
|
42
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
43
|
+
} else {
|
|
44
|
+
return .init()
|
|
45
|
+
}
|
|
46
|
+
}(), { () -> bridge.std__optional_HapticFeedbackStyle_ in
|
|
47
|
+
if let __unwrappedValue = startHapticFeedbackStyle {
|
|
48
|
+
return bridge.create_std__optional_HapticFeedbackStyle_(__unwrappedValue)
|
|
49
|
+
} else {
|
|
50
|
+
return .init()
|
|
51
|
+
}
|
|
52
|
+
}(), { () -> bridge.std__optional_HapticFeedbackStyle_ in
|
|
53
|
+
if let __unwrappedValue = stopHapticFeedbackStyle {
|
|
54
|
+
return bridge.create_std__optional_HapticFeedbackStyle_(__unwrappedValue)
|
|
55
|
+
} else {
|
|
56
|
+
return .init()
|
|
57
|
+
}
|
|
58
|
+
}())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@inline(__always)
|
|
62
|
+
var autoFinishRecognitionMs: Double? {
|
|
63
|
+
return { () -> Double? in
|
|
64
|
+
if bridge.has_value_std__optional_double_(self.__autoFinishRecognitionMs) {
|
|
65
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__autoFinishRecognitionMs)
|
|
66
|
+
return __unwrapped
|
|
67
|
+
} else {
|
|
68
|
+
return nil
|
|
69
|
+
}
|
|
70
|
+
}()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@inline(__always)
|
|
74
|
+
var autoFinishProgressIntervalMs: Double? {
|
|
75
|
+
return { () -> Double? in
|
|
76
|
+
if bridge.has_value_std__optional_double_(self.__autoFinishProgressIntervalMs) {
|
|
77
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__autoFinishProgressIntervalMs)
|
|
78
|
+
return __unwrapped
|
|
79
|
+
} else {
|
|
80
|
+
return nil
|
|
81
|
+
}
|
|
82
|
+
}()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@inline(__always)
|
|
86
|
+
var resetAutoFinishVoiceSensitivity: Double? {
|
|
87
|
+
return { () -> Double? in
|
|
88
|
+
if bridge.has_value_std__optional_double_(self.__resetAutoFinishVoiceSensitivity) {
|
|
89
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__resetAutoFinishVoiceSensitivity)
|
|
90
|
+
return __unwrapped
|
|
91
|
+
} else {
|
|
92
|
+
return nil
|
|
93
|
+
}
|
|
94
|
+
}()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@inline(__always)
|
|
98
|
+
var disableRepeatingFilter: Bool? {
|
|
99
|
+
return { () -> Bool? in
|
|
100
|
+
if bridge.has_value_std__optional_bool_(self.__disableRepeatingFilter) {
|
|
101
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__disableRepeatingFilter)
|
|
102
|
+
return __unwrapped
|
|
103
|
+
} else {
|
|
104
|
+
return nil
|
|
105
|
+
}
|
|
106
|
+
}()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@inline(__always)
|
|
110
|
+
var startHapticFeedbackStyle: HapticFeedbackStyle? {
|
|
111
|
+
return self.__startHapticFeedbackStyle.value
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@inline(__always)
|
|
115
|
+
var stopHapticFeedbackStyle: HapticFeedbackStyle? {
|
|
116
|
+
return self.__stopHapticFeedbackStyle.value
|
|
117
|
+
}
|
|
118
|
+
}
|