@gmessier/nitro-speech 0.3.2 → 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 +2 -6
- package/nitrogen/generated/android/NitroSpeech+autolinking.cmake +2 -2
- package/nitrogen/generated/android/NitroSpeechOnLoad.cpp +5 -3
- 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/NitroSpeechAutolinking.swift +2 -2
- 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
package/nitrogen/generated/ios/swift/{SpeechToTextParams.swift → SpeechRecognitionConfig.swift}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// SpeechRecognitionConfig.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -8,35 +8,23 @@
|
|
|
8
8
|
import NitroModules
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Represents an instance of `
|
|
11
|
+
* Represents an instance of `SpeechRecognitionConfig`, backed by a C++ struct.
|
|
12
12
|
*/
|
|
13
|
-
public typealias
|
|
13
|
+
public typealias SpeechRecognitionConfig = margelo.nitro.nitrospeech.SpeechRecognitionConfig
|
|
14
14
|
|
|
15
|
-
public extension
|
|
15
|
+
public extension SpeechRecognitionConfig {
|
|
16
16
|
private typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Create a new instance of `
|
|
19
|
+
* Create a new instance of `SpeechRecognitionConfig`.
|
|
20
20
|
*/
|
|
21
|
-
init(locale: String?, autoFinishRecognitionMs: Double?,
|
|
21
|
+
init(locale: String?, contextualStrings: [String]?, maskOffensiveWords: Bool?, autoFinishRecognitionMs: Double?, autoFinishProgressIntervalMs: Double?, resetAutoFinishVoiceSensitivity: Double?, disableRepeatingFilter: Bool?, startHapticFeedbackStyle: HapticFeedbackStyle?, stopHapticFeedbackStyle: HapticFeedbackStyle?, androidFormattingPreferQuality: Bool?, androidUseWebSearchModel: Bool?, androidDisableBatchHandling: Bool?, iosAddPunctuation: Bool?, iosPreset: IosPreset?, iosAtypicalSpeech: Bool?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
23
|
if let __unwrappedValue = locale {
|
|
24
24
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
25
|
} else {
|
|
26
26
|
return .init()
|
|
27
27
|
}
|
|
28
|
-
}(), { () -> bridge.std__optional_double_ in
|
|
29
|
-
if let __unwrappedValue = autoFinishRecognitionMs {
|
|
30
|
-
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
31
|
-
} else {
|
|
32
|
-
return .init()
|
|
33
|
-
}
|
|
34
|
-
}(), { () -> bridge.std__optional_bool_ in
|
|
35
|
-
if let __unwrappedValue = disableRepeatingFilter {
|
|
36
|
-
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
37
|
-
} else {
|
|
38
|
-
return .init()
|
|
39
|
-
}
|
|
40
28
|
}(), { () -> bridge.std__optional_std__vector_std__string__ in
|
|
41
29
|
if let __unwrappedValue = contextualStrings {
|
|
42
30
|
return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
|
|
@@ -49,6 +37,36 @@ public extension SpeechToTextParams {
|
|
|
49
37
|
} else {
|
|
50
38
|
return .init()
|
|
51
39
|
}
|
|
40
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
41
|
+
if let __unwrappedValue = maskOffensiveWords {
|
|
42
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
43
|
+
} else {
|
|
44
|
+
return .init()
|
|
45
|
+
}
|
|
46
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
47
|
+
if let __unwrappedValue = autoFinishRecognitionMs {
|
|
48
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
49
|
+
} else {
|
|
50
|
+
return .init()
|
|
51
|
+
}
|
|
52
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
53
|
+
if let __unwrappedValue = autoFinishProgressIntervalMs {
|
|
54
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
55
|
+
} else {
|
|
56
|
+
return .init()
|
|
57
|
+
}
|
|
58
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
59
|
+
if let __unwrappedValue = resetAutoFinishVoiceSensitivity {
|
|
60
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
61
|
+
} else {
|
|
62
|
+
return .init()
|
|
63
|
+
}
|
|
64
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
65
|
+
if let __unwrappedValue = disableRepeatingFilter {
|
|
66
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
67
|
+
} else {
|
|
68
|
+
return .init()
|
|
69
|
+
}
|
|
52
70
|
}(), { () -> bridge.std__optional_HapticFeedbackStyle_ in
|
|
53
71
|
if let __unwrappedValue = startHapticFeedbackStyle {
|
|
54
72
|
return bridge.create_std__optional_HapticFeedbackStyle_(__unwrappedValue)
|
|
@@ -62,31 +80,37 @@ public extension SpeechToTextParams {
|
|
|
62
80
|
return .init()
|
|
63
81
|
}
|
|
64
82
|
}(), { () -> bridge.std__optional_bool_ in
|
|
65
|
-
if let __unwrappedValue =
|
|
83
|
+
if let __unwrappedValue = androidFormattingPreferQuality {
|
|
66
84
|
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
67
85
|
} else {
|
|
68
86
|
return .init()
|
|
69
87
|
}
|
|
70
88
|
}(), { () -> bridge.std__optional_bool_ in
|
|
71
|
-
if let __unwrappedValue =
|
|
89
|
+
if let __unwrappedValue = androidUseWebSearchModel {
|
|
72
90
|
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
73
91
|
} else {
|
|
74
92
|
return .init()
|
|
75
93
|
}
|
|
76
94
|
}(), { () -> bridge.std__optional_bool_ in
|
|
77
|
-
if let __unwrappedValue =
|
|
95
|
+
if let __unwrappedValue = androidDisableBatchHandling {
|
|
78
96
|
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
79
97
|
} else {
|
|
80
98
|
return .init()
|
|
81
99
|
}
|
|
82
100
|
}(), { () -> bridge.std__optional_bool_ in
|
|
83
|
-
if let __unwrappedValue =
|
|
101
|
+
if let __unwrappedValue = iosAddPunctuation {
|
|
84
102
|
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
85
103
|
} else {
|
|
86
104
|
return .init()
|
|
87
105
|
}
|
|
106
|
+
}(), { () -> bridge.std__optional_IosPreset_ in
|
|
107
|
+
if let __unwrappedValue = iosPreset {
|
|
108
|
+
return bridge.create_std__optional_IosPreset_(__unwrappedValue)
|
|
109
|
+
} else {
|
|
110
|
+
return .init()
|
|
111
|
+
}
|
|
88
112
|
}(), { () -> bridge.std__optional_bool_ in
|
|
89
|
-
if let __unwrappedValue =
|
|
113
|
+
if let __unwrappedValue = iosAtypicalSpeech {
|
|
90
114
|
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
91
115
|
} else {
|
|
92
116
|
return .init()
|
|
@@ -107,11 +131,11 @@ public extension SpeechToTextParams {
|
|
|
107
131
|
}
|
|
108
132
|
|
|
109
133
|
@inline(__always)
|
|
110
|
-
var
|
|
111
|
-
return { () ->
|
|
112
|
-
if bridge.
|
|
113
|
-
let __unwrapped = bridge.
|
|
114
|
-
return __unwrapped
|
|
134
|
+
var contextualStrings: [String]? {
|
|
135
|
+
return { () -> [String]? in
|
|
136
|
+
if bridge.has_value_std__optional_std__vector_std__string__(self.__contextualStrings) {
|
|
137
|
+
let __unwrapped = bridge.get_std__optional_std__vector_std__string__(self.__contextualStrings)
|
|
138
|
+
return __unwrapped.map({ __item in String(__item) })
|
|
115
139
|
} else {
|
|
116
140
|
return nil
|
|
117
141
|
}
|
|
@@ -119,10 +143,10 @@ public extension SpeechToTextParams {
|
|
|
119
143
|
}
|
|
120
144
|
|
|
121
145
|
@inline(__always)
|
|
122
|
-
var
|
|
146
|
+
var maskOffensiveWords: Bool? {
|
|
123
147
|
return { () -> Bool? in
|
|
124
|
-
if bridge.has_value_std__optional_bool_(self.
|
|
125
|
-
let __unwrapped = bridge.get_std__optional_bool_(self.
|
|
148
|
+
if bridge.has_value_std__optional_bool_(self.__maskOffensiveWords) {
|
|
149
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__maskOffensiveWords)
|
|
126
150
|
return __unwrapped
|
|
127
151
|
} else {
|
|
128
152
|
return nil
|
|
@@ -131,11 +155,11 @@ public extension SpeechToTextParams {
|
|
|
131
155
|
}
|
|
132
156
|
|
|
133
157
|
@inline(__always)
|
|
134
|
-
var
|
|
135
|
-
return { () ->
|
|
136
|
-
if bridge.
|
|
137
|
-
let __unwrapped = bridge.
|
|
138
|
-
return __unwrapped
|
|
158
|
+
var autoFinishRecognitionMs: Double? {
|
|
159
|
+
return { () -> Double? in
|
|
160
|
+
if bridge.has_value_std__optional_double_(self.__autoFinishRecognitionMs) {
|
|
161
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__autoFinishRecognitionMs)
|
|
162
|
+
return __unwrapped
|
|
139
163
|
} else {
|
|
140
164
|
return nil
|
|
141
165
|
}
|
|
@@ -143,20 +167,34 @@ public extension SpeechToTextParams {
|
|
|
143
167
|
}
|
|
144
168
|
|
|
145
169
|
@inline(__always)
|
|
146
|
-
var
|
|
147
|
-
return
|
|
170
|
+
var autoFinishProgressIntervalMs: Double? {
|
|
171
|
+
return { () -> Double? in
|
|
172
|
+
if bridge.has_value_std__optional_double_(self.__autoFinishProgressIntervalMs) {
|
|
173
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__autoFinishProgressIntervalMs)
|
|
174
|
+
return __unwrapped
|
|
175
|
+
} else {
|
|
176
|
+
return nil
|
|
177
|
+
}
|
|
178
|
+
}()
|
|
148
179
|
}
|
|
149
180
|
|
|
150
181
|
@inline(__always)
|
|
151
|
-
var
|
|
152
|
-
return
|
|
182
|
+
var resetAutoFinishVoiceSensitivity: Double? {
|
|
183
|
+
return { () -> Double? in
|
|
184
|
+
if bridge.has_value_std__optional_double_(self.__resetAutoFinishVoiceSensitivity) {
|
|
185
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__resetAutoFinishVoiceSensitivity)
|
|
186
|
+
return __unwrapped
|
|
187
|
+
} else {
|
|
188
|
+
return nil
|
|
189
|
+
}
|
|
190
|
+
}()
|
|
153
191
|
}
|
|
154
192
|
|
|
155
193
|
@inline(__always)
|
|
156
|
-
var
|
|
194
|
+
var disableRepeatingFilter: Bool? {
|
|
157
195
|
return { () -> Bool? in
|
|
158
|
-
if bridge.has_value_std__optional_bool_(self.
|
|
159
|
-
let __unwrapped = bridge.get_std__optional_bool_(self.
|
|
196
|
+
if bridge.has_value_std__optional_bool_(self.__disableRepeatingFilter) {
|
|
197
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__disableRepeatingFilter)
|
|
160
198
|
return __unwrapped
|
|
161
199
|
} else {
|
|
162
200
|
return nil
|
|
@@ -164,6 +202,16 @@ public extension SpeechToTextParams {
|
|
|
164
202
|
}()
|
|
165
203
|
}
|
|
166
204
|
|
|
205
|
+
@inline(__always)
|
|
206
|
+
var startHapticFeedbackStyle: HapticFeedbackStyle? {
|
|
207
|
+
return self.__startHapticFeedbackStyle.value
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@inline(__always)
|
|
211
|
+
var stopHapticFeedbackStyle: HapticFeedbackStyle? {
|
|
212
|
+
return self.__stopHapticFeedbackStyle.value
|
|
213
|
+
}
|
|
214
|
+
|
|
167
215
|
@inline(__always)
|
|
168
216
|
var androidFormattingPreferQuality: Bool? {
|
|
169
217
|
return { () -> Bool? in
|
|
@@ -211,4 +259,21 @@ public extension SpeechToTextParams {
|
|
|
211
259
|
}
|
|
212
260
|
}()
|
|
213
261
|
}
|
|
262
|
+
|
|
263
|
+
@inline(__always)
|
|
264
|
+
var iosPreset: IosPreset? {
|
|
265
|
+
return self.__iosPreset.value
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@inline(__always)
|
|
269
|
+
var iosAtypicalSpeech: Bool? {
|
|
270
|
+
return { () -> Bool? in
|
|
271
|
+
if bridge.has_value_std__optional_bool_(self.__iosAtypicalSpeech) {
|
|
272
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__iosAtypicalSpeech)
|
|
273
|
+
return __unwrapped
|
|
274
|
+
} else {
|
|
275
|
+
return nil
|
|
276
|
+
}
|
|
277
|
+
}()
|
|
278
|
+
}
|
|
214
279
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// 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
|
+
* Represents an instance of `VolumeChangeEvent`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias VolumeChangeEvent = margelo.nitro.nitrospeech.VolumeChangeEvent
|
|
14
|
+
|
|
15
|
+
public extension VolumeChangeEvent {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitrospeech.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `VolumeChangeEvent`.
|
|
20
|
+
*/
|
|
21
|
+
init(smoothedVolume: Double, rawVolume: Double, db: Double?) {
|
|
22
|
+
self.init(smoothedVolume, rawVolume, { () -> bridge.std__optional_double_ in
|
|
23
|
+
if let __unwrappedValue = db {
|
|
24
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var smoothedVolume: Double {
|
|
33
|
+
return self.__smoothedVolume
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@inline(__always)
|
|
37
|
+
var rawVolume: Double {
|
|
38
|
+
return self.__rawVolume
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@inline(__always)
|
|
42
|
+
var db: Double? {
|
|
43
|
+
return { () -> Double? in
|
|
44
|
+
if bridge.has_value_std__optional_double_(self.__db) {
|
|
45
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__db)
|
|
46
|
+
return __unwrapped
|
|
47
|
+
} else {
|
|
48
|
+
return nil
|
|
49
|
+
}
|
|
50
|
+
}()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -28,11 +28,14 @@ namespace margelo::nitro::nitrospeech {
|
|
|
28
28
|
prototype.registerHybridSetter("onPermissionDenied", &HybridRecognizerSpec::setOnPermissionDenied);
|
|
29
29
|
prototype.registerHybridGetter("onVolumeChange", &HybridRecognizerSpec::getOnVolumeChange);
|
|
30
30
|
prototype.registerHybridSetter("onVolumeChange", &HybridRecognizerSpec::setOnVolumeChange);
|
|
31
|
+
prototype.registerHybridMethod("prewarm", &HybridRecognizerSpec::prewarm);
|
|
31
32
|
prototype.registerHybridMethod("startListening", &HybridRecognizerSpec::startListening);
|
|
32
33
|
prototype.registerHybridMethod("stopListening", &HybridRecognizerSpec::stopListening);
|
|
34
|
+
prototype.registerHybridMethod("resetAutoFinishTime", &HybridRecognizerSpec::resetAutoFinishTime);
|
|
33
35
|
prototype.registerHybridMethod("addAutoFinishTime", &HybridRecognizerSpec::addAutoFinishTime);
|
|
34
|
-
prototype.registerHybridMethod("
|
|
36
|
+
prototype.registerHybridMethod("updateConfig", &HybridRecognizerSpec::updateConfig);
|
|
35
37
|
prototype.registerHybridMethod("getIsActive", &HybridRecognizerSpec::getIsActive);
|
|
38
|
+
prototype.registerHybridMethod("getSupportedLocalesIOS", &HybridRecognizerSpec::getSupportedLocalesIOS);
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -13,14 +13,21 @@
|
|
|
13
13
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
-
// Forward declaration of `
|
|
17
|
-
namespace margelo::nitro::nitrospeech { struct
|
|
16
|
+
// Forward declaration of `VolumeChangeEvent` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrospeech { struct VolumeChangeEvent; }
|
|
18
|
+
// Forward declaration of `SpeechRecognitionConfig` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::nitrospeech { struct SpeechRecognitionConfig; }
|
|
20
|
+
// Forward declaration of `MutableSpeechRecognitionConfig` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::nitrospeech { struct MutableSpeechRecognitionConfig; }
|
|
18
22
|
|
|
19
23
|
#include <functional>
|
|
20
24
|
#include <optional>
|
|
21
25
|
#include <string>
|
|
22
26
|
#include <vector>
|
|
23
|
-
#include "
|
|
27
|
+
#include "VolumeChangeEvent.hpp"
|
|
28
|
+
#include <NitroModules/Promise.hpp>
|
|
29
|
+
#include "SpeechRecognitionConfig.hpp"
|
|
30
|
+
#include "MutableSpeechRecognitionConfig.hpp"
|
|
24
31
|
|
|
25
32
|
namespace margelo::nitro::nitrospeech {
|
|
26
33
|
|
|
@@ -61,16 +68,19 @@ namespace margelo::nitro::nitrospeech {
|
|
|
61
68
|
virtual void setOnError(const std::optional<std::function<void(const std::string& /* message */)>>& onError) = 0;
|
|
62
69
|
virtual std::optional<std::function<void()>> getOnPermissionDenied() = 0;
|
|
63
70
|
virtual void setOnPermissionDenied(const std::optional<std::function<void()>>& onPermissionDenied) = 0;
|
|
64
|
-
virtual std::optional<std::function<void(
|
|
65
|
-
virtual void setOnVolumeChange(const std::optional<std::function<void(
|
|
71
|
+
virtual std::optional<std::function<void(const VolumeChangeEvent& /* event */)>> getOnVolumeChange() = 0;
|
|
72
|
+
virtual void setOnVolumeChange(const std::optional<std::function<void(const VolumeChangeEvent& /* event */)>>& onVolumeChange) = 0;
|
|
66
73
|
|
|
67
74
|
public:
|
|
68
75
|
// Methods
|
|
69
|
-
virtual void
|
|
76
|
+
virtual std::shared_ptr<Promise<void>> prewarm(const std::optional<SpeechRecognitionConfig>& defaultParams) = 0;
|
|
77
|
+
virtual void startListening(const std::optional<SpeechRecognitionConfig>& params) = 0;
|
|
70
78
|
virtual void stopListening() = 0;
|
|
79
|
+
virtual void resetAutoFinishTime() = 0;
|
|
71
80
|
virtual void addAutoFinishTime(std::optional<double> additionalTimeMs) = 0;
|
|
72
|
-
virtual void
|
|
81
|
+
virtual void updateConfig(const std::optional<MutableSpeechRecognitionConfig>& newConfig, std::optional<bool> resetAutoFinishTime) = 0;
|
|
73
82
|
virtual bool getIsActive() = 0;
|
|
83
|
+
virtual std::vector<std::string> getSupportedLocalesIOS() = 0;
|
|
74
84
|
|
|
75
85
|
protected:
|
|
76
86
|
// Hybrid Setup
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IosPreset.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitrospeech {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (IosPreset).
|
|
30
|
+
*/
|
|
31
|
+
enum class IosPreset {
|
|
32
|
+
SHORTFORM SWIFT_NAME(shortform) = 0,
|
|
33
|
+
GENERAL SWIFT_NAME(general) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::nitrospeech
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
// C++ IosPreset <> JS IosPreset (union)
|
|
41
|
+
template <>
|
|
42
|
+
struct JSIConverter<margelo::nitro::nitrospeech::IosPreset> final {
|
|
43
|
+
static inline margelo::nitro::nitrospeech::IosPreset fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
|
+
case hashString("shortform"): return margelo::nitro::nitrospeech::IosPreset::SHORTFORM;
|
|
47
|
+
case hashString("general"): return margelo::nitro::nitrospeech::IosPreset::GENERAL;
|
|
48
|
+
default: [[unlikely]]
|
|
49
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum IosPreset - invalid value!");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrospeech::IosPreset arg) {
|
|
53
|
+
switch (arg) {
|
|
54
|
+
case margelo::nitro::nitrospeech::IosPreset::SHORTFORM: return JSIConverter<std::string>::toJSI(runtime, "shortform");
|
|
55
|
+
case margelo::nitro::nitrospeech::IosPreset::GENERAL: return JSIConverter<std::string>::toJSI(runtime, "general");
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert IosPreset to JS - invalid value: "
|
|
58
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isString()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
|
+
case hashString("shortform"):
|
|
68
|
+
case hashString("general"):
|
|
69
|
+
return true;
|
|
70
|
+
default:
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MutableSpeechRecognitionConfig.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `HapticFeedbackStyle` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitrospeech { enum class HapticFeedbackStyle; }
|
|
33
|
+
|
|
34
|
+
#include <optional>
|
|
35
|
+
#include "HapticFeedbackStyle.hpp"
|
|
36
|
+
|
|
37
|
+
namespace margelo::nitro::nitrospeech {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A struct which can be represented as a JavaScript object (MutableSpeechRecognitionConfig).
|
|
41
|
+
*/
|
|
42
|
+
struct MutableSpeechRecognitionConfig final {
|
|
43
|
+
public:
|
|
44
|
+
std::optional<double> autoFinishRecognitionMs SWIFT_PRIVATE;
|
|
45
|
+
std::optional<double> autoFinishProgressIntervalMs SWIFT_PRIVATE;
|
|
46
|
+
std::optional<double> resetAutoFinishVoiceSensitivity SWIFT_PRIVATE;
|
|
47
|
+
std::optional<bool> disableRepeatingFilter SWIFT_PRIVATE;
|
|
48
|
+
std::optional<HapticFeedbackStyle> startHapticFeedbackStyle SWIFT_PRIVATE;
|
|
49
|
+
std::optional<HapticFeedbackStyle> stopHapticFeedbackStyle SWIFT_PRIVATE;
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
MutableSpeechRecognitionConfig() = default;
|
|
53
|
+
explicit MutableSpeechRecognitionConfig(std::optional<double> autoFinishRecognitionMs, std::optional<double> autoFinishProgressIntervalMs, std::optional<double> resetAutoFinishVoiceSensitivity, std::optional<bool> disableRepeatingFilter, std::optional<HapticFeedbackStyle> startHapticFeedbackStyle, std::optional<HapticFeedbackStyle> stopHapticFeedbackStyle): autoFinishRecognitionMs(autoFinishRecognitionMs), autoFinishProgressIntervalMs(autoFinishProgressIntervalMs), resetAutoFinishVoiceSensitivity(resetAutoFinishVoiceSensitivity), disableRepeatingFilter(disableRepeatingFilter), startHapticFeedbackStyle(startHapticFeedbackStyle), stopHapticFeedbackStyle(stopHapticFeedbackStyle) {}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
friend bool operator==(const MutableSpeechRecognitionConfig& lhs, const MutableSpeechRecognitionConfig& rhs) = default;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace margelo::nitro::nitrospeech
|
|
60
|
+
|
|
61
|
+
namespace margelo::nitro {
|
|
62
|
+
|
|
63
|
+
// C++ MutableSpeechRecognitionConfig <> JS MutableSpeechRecognitionConfig (object)
|
|
64
|
+
template <>
|
|
65
|
+
struct JSIConverter<margelo::nitro::nitrospeech::MutableSpeechRecognitionConfig> final {
|
|
66
|
+
static inline margelo::nitro::nitrospeech::MutableSpeechRecognitionConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
67
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
68
|
+
return margelo::nitro::nitrospeech::MutableSpeechRecognitionConfig(
|
|
69
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoFinishRecognitionMs"))),
|
|
70
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoFinishProgressIntervalMs"))),
|
|
71
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resetAutoFinishVoiceSensitivity"))),
|
|
72
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "disableRepeatingFilter"))),
|
|
73
|
+
JSIConverter<std::optional<margelo::nitro::nitrospeech::HapticFeedbackStyle>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startHapticFeedbackStyle"))),
|
|
74
|
+
JSIConverter<std::optional<margelo::nitro::nitrospeech::HapticFeedbackStyle>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stopHapticFeedbackStyle")))
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrospeech::MutableSpeechRecognitionConfig& arg) {
|
|
78
|
+
jsi::Object obj(runtime);
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "autoFinishRecognitionMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.autoFinishRecognitionMs));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "autoFinishProgressIntervalMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.autoFinishProgressIntervalMs));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "resetAutoFinishVoiceSensitivity"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.resetAutoFinishVoiceSensitivity));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "disableRepeatingFilter"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.disableRepeatingFilter));
|
|
83
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "startHapticFeedbackStyle"), JSIConverter<std::optional<margelo::nitro::nitrospeech::HapticFeedbackStyle>>::toJSI(runtime, arg.startHapticFeedbackStyle));
|
|
84
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "stopHapticFeedbackStyle"), JSIConverter<std::optional<margelo::nitro::nitrospeech::HapticFeedbackStyle>>::toJSI(runtime, arg.stopHapticFeedbackStyle));
|
|
85
|
+
return obj;
|
|
86
|
+
}
|
|
87
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
88
|
+
if (!value.isObject()) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
jsi::Object obj = value.getObject(runtime);
|
|
92
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoFinishRecognitionMs")))) return false;
|
|
96
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoFinishProgressIntervalMs")))) return false;
|
|
97
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resetAutoFinishVoiceSensitivity")))) return false;
|
|
98
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "disableRepeatingFilter")))) return false;
|
|
99
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitrospeech::HapticFeedbackStyle>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startHapticFeedbackStyle")))) return false;
|
|
100
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitrospeech::HapticFeedbackStyle>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stopHapticFeedbackStyle")))) return false;
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
} // namespace margelo::nitro
|