@gmessier/nitro-speech 0.1.3 → 0.3.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/README.md +72 -11
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/HapticImpact.kt +11 -1
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/HybridRecognizer.kt +12 -6
- package/android/src/main/java/com/margelo/nitro/nitrospeech/recognizer/RecognitionListenerSession.kt +73 -7
- package/ios/AnylyzerTranscriber.swift +331 -0
- package/ios/AutoStopper.swift +9 -10
- package/ios/BufferUtil.swift +80 -0
- package/ios/HapticImpact.swift +12 -3
- package/ios/HybridNitroSpeech.swift +10 -1
- package/ios/HybridRecognizer.swift +139 -167
- package/ios/LegacySpeechRecognizer.swift +161 -0
- package/lib/commonjs/index.js +54 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +52 -3
- package/lib/module/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/typescript/index.d.ts +25 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/specs/NitroSpeech.nitro.d.ts +24 -12
- package/lib/typescript/specs/NitroSpeech.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroSpeech+autolinking.cmake +1 -1
- package/nitrogen/generated/android/NitroSpeech+autolinking.gradle +1 -1
- package/nitrogen/generated/android/NitroSpeechOnLoad.cpp +32 -22
- package/nitrogen/generated/android/NitroSpeechOnLoad.hpp +14 -5
- package/nitrogen/generated/android/c++/JFunc_void.hpp +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp +1 -1
- package/nitrogen/generated/android/c++/JHapticFeedbackStyle.hpp +7 -5
- package/nitrogen/generated/android/c++/JHybridNitroSpeechSpec.cpp +23 -22
- package/nitrogen/generated/android/c++/JHybridNitroSpeechSpec.hpp +20 -22
- package/nitrogen/generated/android/c++/JHybridRecognizerSpec.cpp +58 -35
- package/nitrogen/generated/android/c++/JHybridRecognizerSpec.hpp +23 -22
- package/nitrogen/generated/android/c++/JSpeechToTextParams.hpp +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_double.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_std__string.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/Func_void_std__vector_std__string_.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HapticFeedbackStyle.kt +5 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridNitroSpeechSpec.kt +16 -19
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/HybridRecognizerSpec.kt +34 -19
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/NitroSpeechOnLoad.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrospeech/SpeechToTextParams.kt +5 -5
- package/nitrogen/generated/ios/NitroSpeech+autolinking.rb +2 -2
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Bridge.hpp +34 -10
- package/nitrogen/generated/ios/NitroSpeech-Swift-Cxx-Umbrella.hpp +1 -1
- package/nitrogen/generated/ios/NitroSpeechAutolinking.mm +1 -1
- package/nitrogen/generated/ios/NitroSpeechAutolinking.swift +9 -8
- package/nitrogen/generated/ios/c++/HybridNitroSpeechSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridNitroSpeechSpecSwift.hpp +7 -1
- package/nitrogen/generated/ios/c++/HybridRecognizerSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridRecognizerSpecSwift.hpp +22 -1
- package/nitrogen/generated/ios/swift/Func_void.swift +1 -2
- package/nitrogen/generated/ios/swift/Func_void_double.swift +1 -2
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +1 -2
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +1 -2
- package/nitrogen/generated/ios/swift/HapticFeedbackStyle.swift +5 -1
- package/nitrogen/generated/ios/swift/HybridNitroSpeechSpec.swift +3 -4
- package/nitrogen/generated/ios/swift/HybridNitroSpeechSpec_cxx.swift +10 -3
- package/nitrogen/generated/ios/swift/HybridRecognizerSpec.swift +5 -4
- package/nitrogen/generated/ios/swift/HybridRecognizerSpec_cxx.swift +61 -3
- package/nitrogen/generated/ios/swift/SpeechToTextParams.swift +89 -221
- package/nitrogen/generated/shared/c++/HapticFeedbackStyle.hpp +5 -1
- package/nitrogen/generated/shared/c++/HybridNitroSpeechSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroSpeechSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridRecognizerSpec.cpp +4 -1
- package/nitrogen/generated/shared/c++/HybridRecognizerSpec.hpp +4 -1
- package/nitrogen/generated/shared/c++/SpeechToTextParams.hpp +45 -37
- package/package.json +11 -8
- package/src/index.ts +59 -2
- package/src/specs/NitroSpeech.nitro.ts +25 -12
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { type HybridObject } from 'react-native-nitro-modules';
|
|
2
2
|
interface ParamsAndroid {
|
|
3
|
-
/**
|
|
4
|
-
* Default - false
|
|
5
|
-
*
|
|
6
|
-
* Min Android 13
|
|
7
|
-
*/
|
|
8
|
-
androidMaskOffensiveWords?: boolean;
|
|
9
3
|
/**
|
|
10
4
|
* Default - false
|
|
11
5
|
*
|
|
12
6
|
* Prefer quality over latency (may break autofinish timing, depends on engine)
|
|
13
7
|
*
|
|
14
|
-
*
|
|
8
|
+
* Android 13+
|
|
15
9
|
*/
|
|
16
10
|
androidFormattingPreferQuality?: boolean;
|
|
17
11
|
/**
|
|
@@ -37,11 +31,11 @@ interface ParamsIOS {
|
|
|
37
31
|
*
|
|
38
32
|
* Adds punctuation to speech recognition results
|
|
39
33
|
*
|
|
40
|
-
*
|
|
34
|
+
* iOS 16+
|
|
41
35
|
*/
|
|
42
36
|
iosAddPunctuation?: boolean;
|
|
43
37
|
}
|
|
44
|
-
type HapticFeedbackStyle = 'light' | 'medium' | 'heavy';
|
|
38
|
+
type HapticFeedbackStyle = 'light' | 'medium' | 'heavy' | 'none';
|
|
45
39
|
export interface SpeechToTextParams extends ParamsAndroid, ParamsIOS {
|
|
46
40
|
/**
|
|
47
41
|
* Default - "en-US"
|
|
@@ -64,17 +58,25 @@ export interface SpeechToTextParams extends ParamsAndroid, ParamsIOS {
|
|
|
64
58
|
*/
|
|
65
59
|
contextualStrings?: string[];
|
|
66
60
|
/**
|
|
67
|
-
* Default -
|
|
61
|
+
* Default - "medium"
|
|
68
62
|
*
|
|
69
63
|
* Haptic feedback style when microphone starts recording.
|
|
70
64
|
*/
|
|
71
65
|
startHapticFeedbackStyle?: HapticFeedbackStyle;
|
|
72
66
|
/**
|
|
73
|
-
* Default -
|
|
67
|
+
* Default - "medium"
|
|
74
68
|
*
|
|
75
69
|
* Haptic feedback style when microphone stops recording.
|
|
76
70
|
*/
|
|
77
71
|
stopHapticFeedbackStyle?: HapticFeedbackStyle;
|
|
72
|
+
/**
|
|
73
|
+
* Default - false
|
|
74
|
+
*
|
|
75
|
+
* Android 13+
|
|
76
|
+
*
|
|
77
|
+
* iOS 26+ (iOS <26: always `false`)
|
|
78
|
+
*/
|
|
79
|
+
maskOffensiveWords?: boolean;
|
|
78
80
|
}
|
|
79
81
|
export interface Recognizer extends HybridObject<{
|
|
80
82
|
ios: 'swift';
|
|
@@ -111,12 +113,16 @@ export interface Recognizer extends HybridObject<{
|
|
|
111
113
|
* @param withRefresh - if true, will refresh the auto finish progress.
|
|
112
114
|
*/
|
|
113
115
|
updateAutoFinishTime(newTimeMs: number, withRefresh?: boolean): void;
|
|
116
|
+
/**
|
|
117
|
+
* Returns true if the speech recognition is active.
|
|
118
|
+
*/
|
|
119
|
+
getIsActive(): boolean;
|
|
114
120
|
/**
|
|
115
121
|
* The speech recognition has started.
|
|
116
122
|
*/
|
|
117
123
|
onReadyForSpeech?: () => void;
|
|
118
124
|
/**
|
|
119
|
-
* Audio recording has stopped.
|
|
125
|
+
* Audio recording has stopped.
|
|
120
126
|
*/
|
|
121
127
|
onRecordingStopped?: () => void;
|
|
122
128
|
/**
|
|
@@ -139,6 +145,12 @@ export interface Recognizer extends HybridObject<{
|
|
|
139
145
|
* Permission to record audio has been denied.
|
|
140
146
|
*/
|
|
141
147
|
onPermissionDenied?: () => void;
|
|
148
|
+
/**
|
|
149
|
+
* Called with arbitrary frequency (many times per second) while audio recording is active.
|
|
150
|
+
*
|
|
151
|
+
* Voice input volume normalized to a range of 0 to 1.
|
|
152
|
+
*/
|
|
153
|
+
onVolumeChange?: (normVolume: number) => void;
|
|
142
154
|
}
|
|
143
155
|
export interface NitroSpeech extends HybridObject<{
|
|
144
156
|
ios: 'swift';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSpeech.nitro.d.ts","sourceRoot":"","sources":["../../../src/specs/NitroSpeech.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,UAAU,aAAa;IACrB
|
|
1
|
+
{"version":3,"file":"NitroSpeech.nitro.d.ts","sourceRoot":"","sources":["../../../src/specs/NitroSpeech.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,UAAU,aAAa;IACrB;;;;;;OAMG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;;;;;OAMG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAA;CACtC;AAED,UAAU,SAAS;IACjB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,KAAK,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;AAEhE,MAAM,WAAW,kBAAmB,SAAQ,aAAa,EAAE,SAAS;IAClE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,mBAAmB,CAAA;IAC9C;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,mBAAmB,CAAA;IAC7C;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY,CAAC;IAC/C,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,EAAE,QAAQ,CAAA;CAClB,CAAC;IACA;;;;OAIG;IACH,cAAc,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAA;IAChD;;;;;;OAMG;IACH,aAAa,IAAI,IAAI,CAAA;IAErB;;;;;;OAMG;IACH,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAElD;;;;;;;OAOG;IACH,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IAEpE;;OAEG;IACH,WAAW,IAAI,OAAO,CAAA;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC7B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC5C;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAA;IACnD;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC/B;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9C;AAED,MAAM,WAAW,WAAY,SAAQ,YAAY,CAAC;IAChD,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,EAAE,QAAQ,CAAA;CAClB,CAAC;IACA,UAAU,EAAE,UAAU,CAAA;CACvB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# NitroSpeech+autolinking.cmake
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a CMake file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroSpeech+autolinking.gradle
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroSpeechOnLoad.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#ifndef BUILDING_NITROSPEECH_WITH_GENERATED_CMAKE_PROJECT
|
|
@@ -26,29 +26,39 @@
|
|
|
26
26
|
namespace margelo::nitro::nitrospeech {
|
|
27
27
|
|
|
28
28
|
int initialize(JavaVM* vm) {
|
|
29
|
+
return facebook::jni::initialize(vm, []() {
|
|
30
|
+
::margelo::nitro::nitrospeech::registerAllNatives();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
struct JHybridNitroSpeechSpecImpl: public jni::JavaClass<JHybridNitroSpeechSpecImpl, JHybridNitroSpeechSpec::JavaPart> {
|
|
35
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/HybridNitroSpeech;";
|
|
36
|
+
static std::shared_ptr<JHybridNitroSpeechSpec> create() {
|
|
37
|
+
static auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroSpeechSpecImpl::javaobject()>();
|
|
38
|
+
jni::local_ref<JHybridNitroSpeechSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
39
|
+
return javaPart->getJHybridNitroSpeechSpec();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
void registerAllNatives() {
|
|
29
44
|
using namespace margelo::nitro;
|
|
30
45
|
using namespace margelo::nitro::nitrospeech;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
auto instance = object.create();
|
|
48
|
-
return instance->cthis()->shared();
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
});
|
|
46
|
+
|
|
47
|
+
// Register native JNI methods
|
|
48
|
+
margelo::nitro::nitrospeech::JHybridRecognizerSpec::CxxPart::registerNatives();
|
|
49
|
+
margelo::nitro::nitrospeech::JFunc_void_cxx::registerNatives();
|
|
50
|
+
margelo::nitro::nitrospeech::JFunc_void_std__vector_std__string__cxx::registerNatives();
|
|
51
|
+
margelo::nitro::nitrospeech::JFunc_void_double_cxx::registerNatives();
|
|
52
|
+
margelo::nitro::nitrospeech::JFunc_void_std__string_cxx::registerNatives();
|
|
53
|
+
margelo::nitro::nitrospeech::JHybridNitroSpeechSpec::CxxPart::registerNatives();
|
|
54
|
+
|
|
55
|
+
// Register Nitro Hybrid Objects
|
|
56
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
57
|
+
"NitroSpeech",
|
|
58
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
59
|
+
return JHybridNitroSpeechSpecImpl::create();
|
|
60
|
+
}
|
|
61
|
+
);
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
} // namespace margelo::nitro::nitrospeech
|
|
@@ -2,24 +2,33 @@
|
|
|
2
2
|
/// NitroSpeechOnLoad.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include <jni.h>
|
|
9
|
+
#include <functional>
|
|
9
10
|
#include <NitroModules/NitroDefines.hpp>
|
|
10
11
|
|
|
11
12
|
namespace margelo::nitro::nitrospeech {
|
|
12
13
|
|
|
14
|
+
[[deprecated("Use registerNatives() instead.")]]
|
|
15
|
+
int initialize(JavaVM* vm);
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`)
|
|
18
|
+
* Register the native (C++) part of NitroSpeech, and autolinks all Hybrid Objects.
|
|
19
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
|
|
20
|
+
* inside a `facebook::jni::initialize(vm, ...)` call.
|
|
16
21
|
* Example:
|
|
17
22
|
* ```cpp (cpp-adapter.cpp)
|
|
18
23
|
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
-
* return
|
|
24
|
+
* return facebook::jni::initialize(vm, []() {
|
|
25
|
+
* // register all NitroSpeech HybridObjects
|
|
26
|
+
* margelo::nitro::nitrospeech::registerNatives();
|
|
27
|
+
* // any other custom registrations go here.
|
|
28
|
+
* });
|
|
20
29
|
* }
|
|
21
30
|
* ```
|
|
22
31
|
*/
|
|
23
|
-
|
|
32
|
+
void registerAllNatives();
|
|
24
33
|
|
|
25
34
|
} // namespace margelo::nitro::nitrospeech
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// JHapticFeedbackStyle.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -41,17 +41,19 @@ namespace margelo::nitro::nitrospeech {
|
|
|
41
41
|
[[maybe_unused]]
|
|
42
42
|
static jni::alias_ref<JHapticFeedbackStyle> fromCpp(HapticFeedbackStyle value) {
|
|
43
43
|
static const auto clazz = javaClassStatic();
|
|
44
|
-
static const auto fieldLIGHT = clazz->getStaticField<JHapticFeedbackStyle>("LIGHT");
|
|
45
|
-
static const auto fieldMEDIUM = clazz->getStaticField<JHapticFeedbackStyle>("MEDIUM");
|
|
46
|
-
static const auto fieldHEAVY = clazz->getStaticField<JHapticFeedbackStyle>("HEAVY");
|
|
47
|
-
|
|
48
44
|
switch (value) {
|
|
49
45
|
case HapticFeedbackStyle::LIGHT:
|
|
46
|
+
static const auto fieldLIGHT = clazz->getStaticField<JHapticFeedbackStyle>("LIGHT");
|
|
50
47
|
return clazz->getStaticFieldValue(fieldLIGHT);
|
|
51
48
|
case HapticFeedbackStyle::MEDIUM:
|
|
49
|
+
static const auto fieldMEDIUM = clazz->getStaticField<JHapticFeedbackStyle>("MEDIUM");
|
|
52
50
|
return clazz->getStaticFieldValue(fieldMEDIUM);
|
|
53
51
|
case HapticFeedbackStyle::HEAVY:
|
|
52
|
+
static const auto fieldHEAVY = clazz->getStaticField<JHapticFeedbackStyle>("HEAVY");
|
|
54
53
|
return clazz->getStaticFieldValue(fieldHEAVY);
|
|
54
|
+
case HapticFeedbackStyle::NONE:
|
|
55
|
+
static const auto fieldNONE = clazz->getStaticField<JHapticFeedbackStyle>("NONE");
|
|
56
|
+
return clazz->getStaticFieldValue(fieldNONE);
|
|
55
57
|
default:
|
|
56
58
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
57
59
|
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// JHybridNitroSpeechSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "JHybridNitroSpeechSpec.hpp"
|
|
@@ -16,40 +16,41 @@ namespace margelo::nitro::nitrospeech { class HybridRecognizerSpec; }
|
|
|
16
16
|
|
|
17
17
|
namespace margelo::nitro::nitrospeech {
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
19
|
+
std::shared_ptr<JHybridNitroSpeechSpec> JHybridNitroSpeechSpec::JavaPart::getJHybridNitroSpeechSpec() {
|
|
20
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
21
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridNitroSpeechSpec>(hybridObject);
|
|
22
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
23
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridNitroSpeechSpec!");
|
|
24
|
+
}
|
|
25
|
+
return castHybridObject;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return method(_javaPart);
|
|
28
|
+
jni::local_ref<JHybridNitroSpeechSpec::CxxPart::jhybriddata> JHybridNitroSpeechSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
29
|
+
return makeCxxInstance(jThis);
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
std::shared_ptr<JHybridObject> JHybridNitroSpeechSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
33
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridNitroSpeechSpec::JavaPart>(javaPart);
|
|
34
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
35
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridNitroSpeechSpec::JavaPart!");
|
|
36
|
+
}
|
|
37
|
+
return std::make_shared<JHybridNitroSpeechSpec>(castJavaPart);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
void JHybridNitroSpeechSpec::CxxPart::registerNatives() {
|
|
41
|
+
registerHybrid({
|
|
42
|
+
makeNativeMethod("initHybrid", JHybridNitroSpeechSpec::CxxPart::initHybrid),
|
|
43
|
+
});
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
// Properties
|
|
46
47
|
std::shared_ptr<HybridRecognizerSpec> JHybridNitroSpeechSpec::getRecognizer() {
|
|
47
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JHybridRecognizerSpec::
|
|
48
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridRecognizerSpec::JavaPart>()>("getRecognizer");
|
|
48
49
|
auto __result = method(_javaPart);
|
|
49
|
-
return __result->
|
|
50
|
+
return __result->getJHybridRecognizerSpec();
|
|
50
51
|
}
|
|
51
52
|
void JHybridNitroSpeechSpec::setRecognizer(const std::shared_ptr<HybridRecognizerSpec>& recognizer) {
|
|
52
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHybridRecognizerSpec::
|
|
53
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JHybridRecognizerSpec::JavaPart> /* recognizer */)>("setRecognizer");
|
|
53
54
|
method(_javaPart, std::dynamic_pointer_cast<JHybridRecognizerSpec>(recognizer)->getJavaPart());
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridNitroSpeechSpec.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -18,33 +18,33 @@ namespace margelo::nitro::nitrospeech {
|
|
|
18
18
|
|
|
19
19
|
using namespace facebook;
|
|
20
20
|
|
|
21
|
-
class JHybridNitroSpeechSpec: public
|
|
22
|
-
public virtual HybridNitroSpeechSpec {
|
|
21
|
+
class JHybridNitroSpeechSpec: public virtual HybridNitroSpeechSpec, public virtual JHybridObject {
|
|
23
22
|
public:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
HybridBase
|
|
33
|
-
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/HybridNitroSpeechSpec;";
|
|
25
|
+
std::shared_ptr<JHybridNitroSpeechSpec> getJHybridNitroSpeechSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrospeech/HybridNitroSpeechSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
34
35
|
|
|
35
36
|
public:
|
|
37
|
+
explicit JHybridNitroSpeechSpec(const jni::local_ref<JHybridNitroSpeechSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridNitroSpeechSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
36
41
|
~JHybridNitroSpeechSpec() override {
|
|
37
42
|
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
43
|
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
public:
|
|
42
|
-
|
|
43
|
-
void dispose() noexcept override;
|
|
44
|
-
std::string toString() override;
|
|
45
|
-
|
|
46
|
-
public:
|
|
47
|
-
inline const jni::global_ref<JHybridNitroSpeechSpec::javaobject>& getJavaPart() const noexcept {
|
|
47
|
+
inline const jni::global_ref<JHybridNitroSpeechSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
48
|
return _javaPart;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -58,9 +58,7 @@ namespace margelo::nitro::nitrospeech {
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
private:
|
|
61
|
-
|
|
62
|
-
using HybridBase::HybridBase;
|
|
63
|
-
jni::global_ref<JHybridNitroSpeechSpec::javaobject> _javaPart;
|
|
61
|
+
jni::global_ref<JHybridNitroSpeechSpec::JavaPart> _javaPart;
|
|
64
62
|
};
|
|
65
63
|
|
|
66
64
|
} // namespace margelo::nitro::nitrospeech
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// JHybridRecognizerSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "JHybridRecognizerSpec.hpp"
|
|
@@ -28,35 +28,36 @@ namespace margelo::nitro::nitrospeech { enum class HapticFeedbackStyle; }
|
|
|
28
28
|
|
|
29
29
|
namespace margelo::nitro::nitrospeech {
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
std::shared_ptr<JHybridRecognizerSpec> JHybridRecognizerSpec::JavaPart::getJHybridRecognizerSpec() {
|
|
32
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
33
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridRecognizerSpec>(hybridObject);
|
|
34
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
35
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridRecognizerSpec!");
|
|
36
|
+
}
|
|
37
|
+
return castHybridObject;
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
makeNativeMethod("initHybrid", JHybridRecognizerSpec::initHybrid),
|
|
38
|
-
});
|
|
40
|
+
jni::local_ref<JHybridRecognizerSpec::CxxPart::jhybriddata> JHybridRecognizerSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
41
|
+
return makeCxxInstance(jThis);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
std::shared_ptr<JHybridObject> JHybridRecognizerSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
45
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridRecognizerSpec::JavaPart>(javaPart);
|
|
46
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
47
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridRecognizerSpec::JavaPart!");
|
|
48
|
+
}
|
|
49
|
+
return std::make_shared<JHybridRecognizerSpec>(castJavaPart);
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
void JHybridRecognizerSpec::
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
std::string JHybridRecognizerSpec::toString() {
|
|
52
|
-
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
53
|
-
auto javaString = method(_javaPart);
|
|
54
|
-
return javaString->toStdString();
|
|
52
|
+
void JHybridRecognizerSpec::CxxPart::registerNatives() {
|
|
53
|
+
registerHybrid({
|
|
54
|
+
makeNativeMethod("initHybrid", JHybridRecognizerSpec::CxxPart::initHybrid),
|
|
55
|
+
});
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
// Properties
|
|
58
59
|
std::optional<std::function<void()>> JHybridRecognizerSpec::getOnReadyForSpeech() {
|
|
59
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnReadyForSpeech_cxx");
|
|
60
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnReadyForSpeech_cxx");
|
|
60
61
|
auto __result = method(_javaPart);
|
|
61
62
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
|
|
62
63
|
if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -69,11 +70,11 @@ namespace margelo::nitro::nitrospeech {
|
|
|
69
70
|
}()) : std::nullopt;
|
|
70
71
|
}
|
|
71
72
|
void JHybridRecognizerSpec::setOnReadyForSpeech(const std::optional<std::function<void()>>& onReadyForSpeech) {
|
|
72
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onReadyForSpeech */)>("setOnReadyForSpeech_cxx");
|
|
73
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onReadyForSpeech */)>("setOnReadyForSpeech_cxx");
|
|
73
74
|
method(_javaPart, onReadyForSpeech.has_value() ? JFunc_void_cxx::fromCpp(onReadyForSpeech.value()) : nullptr);
|
|
74
75
|
}
|
|
75
76
|
std::optional<std::function<void()>> JHybridRecognizerSpec::getOnRecordingStopped() {
|
|
76
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnRecordingStopped_cxx");
|
|
77
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnRecordingStopped_cxx");
|
|
77
78
|
auto __result = method(_javaPart);
|
|
78
79
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
|
|
79
80
|
if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -86,11 +87,11 @@ namespace margelo::nitro::nitrospeech {
|
|
|
86
87
|
}()) : std::nullopt;
|
|
87
88
|
}
|
|
88
89
|
void JHybridRecognizerSpec::setOnRecordingStopped(const std::optional<std::function<void()>>& onRecordingStopped) {
|
|
89
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onRecordingStopped */)>("setOnRecordingStopped_cxx");
|
|
90
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onRecordingStopped */)>("setOnRecordingStopped_cxx");
|
|
90
91
|
method(_javaPart, onRecordingStopped.has_value() ? JFunc_void_cxx::fromCpp(onRecordingStopped.value()) : nullptr);
|
|
91
92
|
}
|
|
92
93
|
std::optional<std::function<void(const std::vector<std::string>& /* resultBatches */)>> JHybridRecognizerSpec::getOnResult() {
|
|
93
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__vector_std__string_::javaobject>()>("getOnResult_cxx");
|
|
94
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__vector_std__string_::javaobject>()>("getOnResult_cxx");
|
|
94
95
|
auto __result = method(_javaPart);
|
|
95
96
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::vector<std::string>& /* resultBatches */)> {
|
|
96
97
|
if (__result->isInstanceOf(JFunc_void_std__vector_std__string__cxx::javaClassStatic())) [[likely]] {
|
|
@@ -103,11 +104,11 @@ namespace margelo::nitro::nitrospeech {
|
|
|
103
104
|
}()) : std::nullopt;
|
|
104
105
|
}
|
|
105
106
|
void JHybridRecognizerSpec::setOnResult(const std::optional<std::function<void(const std::vector<std::string>& /* resultBatches */)>>& onResult) {
|
|
106
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__vector_std__string_::javaobject> /* onResult */)>("setOnResult_cxx");
|
|
107
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__vector_std__string_::javaobject> /* onResult */)>("setOnResult_cxx");
|
|
107
108
|
method(_javaPart, onResult.has_value() ? JFunc_void_std__vector_std__string__cxx::fromCpp(onResult.value()) : nullptr);
|
|
108
109
|
}
|
|
109
110
|
std::optional<std::function<void(double /* timeLeftMs */)>> JHybridRecognizerSpec::getOnAutoFinishProgress() {
|
|
110
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_double::javaobject>()>("getOnAutoFinishProgress_cxx");
|
|
111
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_double::javaobject>()>("getOnAutoFinishProgress_cxx");
|
|
111
112
|
auto __result = method(_javaPart);
|
|
112
113
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void(double /* timeLeftMs */)> {
|
|
113
114
|
if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -120,11 +121,11 @@ namespace margelo::nitro::nitrospeech {
|
|
|
120
121
|
}()) : std::nullopt;
|
|
121
122
|
}
|
|
122
123
|
void JHybridRecognizerSpec::setOnAutoFinishProgress(const std::optional<std::function<void(double /* timeLeftMs */)>>& onAutoFinishProgress) {
|
|
123
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_double::javaobject> /* onAutoFinishProgress */)>("setOnAutoFinishProgress_cxx");
|
|
124
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_double::javaobject> /* onAutoFinishProgress */)>("setOnAutoFinishProgress_cxx");
|
|
124
125
|
method(_javaPart, onAutoFinishProgress.has_value() ? JFunc_void_double_cxx::fromCpp(onAutoFinishProgress.value()) : nullptr);
|
|
125
126
|
}
|
|
126
127
|
std::optional<std::function<void(const std::string& /* message */)>> JHybridRecognizerSpec::getOnError() {
|
|
127
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnError_cxx");
|
|
128
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnError_cxx");
|
|
128
129
|
auto __result = method(_javaPart);
|
|
129
130
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* message */)> {
|
|
130
131
|
if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -137,11 +138,11 @@ namespace margelo::nitro::nitrospeech {
|
|
|
137
138
|
}()) : std::nullopt;
|
|
138
139
|
}
|
|
139
140
|
void JHybridRecognizerSpec::setOnError(const std::optional<std::function<void(const std::string& /* message */)>>& onError) {
|
|
140
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onError */)>("setOnError_cxx");
|
|
141
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onError */)>("setOnError_cxx");
|
|
141
142
|
method(_javaPart, onError.has_value() ? JFunc_void_std__string_cxx::fromCpp(onError.value()) : nullptr);
|
|
142
143
|
}
|
|
143
144
|
std::optional<std::function<void()>> JHybridRecognizerSpec::getOnPermissionDenied() {
|
|
144
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnPermissionDenied_cxx");
|
|
145
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnPermissionDenied_cxx");
|
|
145
146
|
auto __result = method(_javaPart);
|
|
146
147
|
return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
|
|
147
148
|
if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
|
|
@@ -154,26 +155,48 @@ namespace margelo::nitro::nitrospeech {
|
|
|
154
155
|
}()) : std::nullopt;
|
|
155
156
|
}
|
|
156
157
|
void JHybridRecognizerSpec::setOnPermissionDenied(const std::optional<std::function<void()>>& onPermissionDenied) {
|
|
157
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onPermissionDenied */)>("setOnPermissionDenied_cxx");
|
|
158
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onPermissionDenied */)>("setOnPermissionDenied_cxx");
|
|
158
159
|
method(_javaPart, onPermissionDenied.has_value() ? JFunc_void_cxx::fromCpp(onPermissionDenied.value()) : nullptr);
|
|
159
160
|
}
|
|
161
|
+
std::optional<std::function<void(double /* normVolume */)>> JHybridRecognizerSpec::getOnVolumeChange() {
|
|
162
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_double::javaobject>()>("getOnVolumeChange_cxx");
|
|
163
|
+
auto __result = method(_javaPart);
|
|
164
|
+
return __result != nullptr ? std::make_optional([&]() -> std::function<void(double /* normVolume */)> {
|
|
165
|
+
if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] {
|
|
166
|
+
auto downcast = jni::static_ref_cast<JFunc_void_double_cxx::javaobject>(__result);
|
|
167
|
+
return downcast->cthis()->getFunction();
|
|
168
|
+
} else {
|
|
169
|
+
auto __resultRef = jni::make_global(__result);
|
|
170
|
+
return JNICallable<JFunc_void_double, void(double)>(std::move(__resultRef));
|
|
171
|
+
}
|
|
172
|
+
}()) : std::nullopt;
|
|
173
|
+
}
|
|
174
|
+
void JHybridRecognizerSpec::setOnVolumeChange(const std::optional<std::function<void(double /* normVolume */)>>& onVolumeChange) {
|
|
175
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_double::javaobject> /* onVolumeChange */)>("setOnVolumeChange_cxx");
|
|
176
|
+
method(_javaPart, onVolumeChange.has_value() ? JFunc_void_double_cxx::fromCpp(onVolumeChange.value()) : nullptr);
|
|
177
|
+
}
|
|
160
178
|
|
|
161
179
|
// Methods
|
|
162
180
|
void JHybridRecognizerSpec::startListening(const SpeechToTextParams& params) {
|
|
163
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSpeechToTextParams> /* params */)>("startListening");
|
|
181
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSpeechToTextParams> /* params */)>("startListening");
|
|
164
182
|
method(_javaPart, JSpeechToTextParams::fromCpp(params));
|
|
165
183
|
}
|
|
166
184
|
void JHybridRecognizerSpec::stopListening() {
|
|
167
|
-
static const auto method = javaClassStatic()->getMethod<void()>("stopListening");
|
|
185
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopListening");
|
|
168
186
|
method(_javaPart);
|
|
169
187
|
}
|
|
170
188
|
void JHybridRecognizerSpec::addAutoFinishTime(std::optional<double> additionalTimeMs) {
|
|
171
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* additionalTimeMs */)>("addAutoFinishTime");
|
|
189
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* additionalTimeMs */)>("addAutoFinishTime");
|
|
172
190
|
method(_javaPart, additionalTimeMs.has_value() ? jni::JDouble::valueOf(additionalTimeMs.value()) : nullptr);
|
|
173
191
|
}
|
|
174
192
|
void JHybridRecognizerSpec::updateAutoFinishTime(double newTimeMs, std::optional<bool> withRefresh) {
|
|
175
|
-
static const auto method = javaClassStatic()->getMethod<void(double /* newTimeMs */, jni::alias_ref<jni::JBoolean> /* withRefresh */)>("updateAutoFinishTime");
|
|
193
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* newTimeMs */, jni::alias_ref<jni::JBoolean> /* withRefresh */)>("updateAutoFinishTime");
|
|
176
194
|
method(_javaPart, newTimeMs, withRefresh.has_value() ? jni::JBoolean::valueOf(withRefresh.value()) : nullptr);
|
|
177
195
|
}
|
|
196
|
+
bool JHybridRecognizerSpec::getIsActive() {
|
|
197
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getIsActive");
|
|
198
|
+
auto __result = method(_javaPart);
|
|
199
|
+
return static_cast<bool>(__result);
|
|
200
|
+
}
|
|
178
201
|
|
|
179
202
|
} // namespace margelo::nitro::nitrospeech
|