@iternio/react-native-auto-play 0.4.2 → 0.4.3
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/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +89 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridCluster.kt +0 -1
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +20 -276
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ThreadUtil.kt +13 -6
- package/ios/hybrid/HybridAutoPlay.swift +47 -2
- package/ios/utils/VoiceInputManager.swift +40 -141
- package/lib/hooks/useAndroidAutoTelemetry.js +6 -1
- package/lib/index.d.ts +1 -5
- package/lib/index.js +1 -4
- package/lib/specs/AutoPlay.nitro.d.ts +29 -0
- package/nitro.json +0 -10
- package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +0 -2
- package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +0 -18
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +43 -0
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +17 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +16 -41
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +126 -201
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +0 -11
- package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.mm +0 -8
- package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.swift +0 -12
- package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +34 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +5 -5
- package/nitrogen/generated/ios/swift/{Func_void_VoiceInputResult.swift → Func_void_std__shared_ptr_ArrayBuffer_.swift} +10 -10
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +82 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +5 -0
- package/package.json +1 -1
- package/src/hooks/useAndroidAutoTelemetry.ts +13 -8
- package/src/index.ts +1 -5
- package/src/specs/AutoPlay.nitro.ts +37 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt +0 -95
- package/ios/hybrid/HybridVoice.swift +0 -63
- package/lib/hybrid/HybridVoice.d.ts +0 -12
- package/lib/hybrid/HybridVoice.js +0 -13
- package/lib/specs/Voice.nitro.d.ts +0 -51
- package/lib/specs/Voice.nitro.js +0 -1
- package/lib/types/Voice.d.ts +0 -15
- package/lib/types/Voice.js +0 -1
- package/nitrogen/generated/android/c++/JFunc_void_VoiceInputChunk.hpp +0 -81
- package/nitrogen/generated/android/c++/JHybridVoiceSpec.cpp +0 -104
- package/nitrogen/generated/android/c++/JHybridVoiceSpec.hpp +0 -66
- package/nitrogen/generated/android/c++/JVoiceInputChunk.hpp +0 -64
- package/nitrogen/generated/android/c++/JVoiceInputResult.hpp +0 -64
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VoiceInputChunk.kt +0 -80
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec.kt +0 -72
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputChunk.kt +0 -41
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputResult.kt +0 -41
- package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.hpp +0 -116
- package/nitrogen/generated/ios/swift/Func_void_VoiceInputChunk.swift +0 -46
- package/nitrogen/generated/ios/swift/HybridVoiceSpec.swift +0 -58
- package/nitrogen/generated/ios/swift/HybridVoiceSpec_cxx.swift +0 -227
- package/nitrogen/generated/ios/swift/VoiceInputChunk.swift +0 -60
- package/nitrogen/generated/ios/swift/VoiceInputResult.swift +0 -60
- package/nitrogen/generated/shared/c++/HybridVoiceSpec.cpp +0 -24
- package/nitrogen/generated/shared/c++/HybridVoiceSpec.hpp +0 -73
- package/nitrogen/generated/shared/c++/VoiceInputChunk.hpp +0 -89
- package/nitrogen/generated/shared/c++/VoiceInputResult.hpp +0 -89
- package/src/hybrid/HybridVoice.ts +0 -30
- package/src/specs/Voice.nitro.ts +0 -58
- package/src/types/Voice.ts +0 -17
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// JHybridVoiceSpec.cpp
|
|
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
|
-
#include "JHybridVoiceSpec.hpp"
|
|
9
|
-
|
|
10
|
-
// Forward declaration of `VoiceInputResult` to properly resolve imports.
|
|
11
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct VoiceInputResult; }
|
|
12
|
-
// Forward declaration of `VoiceInputChunk` to properly resolve imports.
|
|
13
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct VoiceInputChunk; }
|
|
14
|
-
|
|
15
|
-
#include <NitroModules/Promise.hpp>
|
|
16
|
-
#include <NitroModules/JPromise.hpp>
|
|
17
|
-
#include "VoiceInputResult.hpp"
|
|
18
|
-
#include "JVoiceInputResult.hpp"
|
|
19
|
-
#include <string>
|
|
20
|
-
#include <optional>
|
|
21
|
-
#include <NitroModules/ArrayBuffer.hpp>
|
|
22
|
-
#include <NitroModules/JArrayBuffer.hpp>
|
|
23
|
-
#include "VoiceInputChunk.hpp"
|
|
24
|
-
#include <functional>
|
|
25
|
-
#include "JFunc_void_VoiceInputChunk.hpp"
|
|
26
|
-
#include <NitroModules/JNICallable.hpp>
|
|
27
|
-
#include "JVoiceInputChunk.hpp"
|
|
28
|
-
|
|
29
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
30
|
-
|
|
31
|
-
std::shared_ptr<JHybridVoiceSpec> JHybridVoiceSpec::JavaPart::getJHybridVoiceSpec() {
|
|
32
|
-
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
33
|
-
auto castHybridObject = std::dynamic_pointer_cast<JHybridVoiceSpec>(hybridObject);
|
|
34
|
-
if (castHybridObject == nullptr) [[unlikely]] {
|
|
35
|
-
throw std::runtime_error("Failed to downcast JHybridObject to JHybridVoiceSpec!");
|
|
36
|
-
}
|
|
37
|
-
return castHybridObject;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
jni::local_ref<JHybridVoiceSpec::CxxPart::jhybriddata> JHybridVoiceSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
41
|
-
return makeCxxInstance(jThis);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
std::shared_ptr<JHybridObject> JHybridVoiceSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
45
|
-
auto castJavaPart = jni::dynamic_ref_cast<JHybridVoiceSpec::JavaPart>(javaPart);
|
|
46
|
-
if (castJavaPart == nullptr) [[unlikely]] {
|
|
47
|
-
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridVoiceSpec::JavaPart!");
|
|
48
|
-
}
|
|
49
|
-
return std::make_shared<JHybridVoiceSpec>(castJavaPart);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
void JHybridVoiceSpec::CxxPart::registerNatives() {
|
|
53
|
-
registerHybrid({
|
|
54
|
-
makeNativeMethod("initHybrid", JHybridVoiceSpec::CxxPart::initHybrid),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Properties
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// Methods
|
|
62
|
-
bool JHybridVoiceSpec::hasVoiceInputPermission() {
|
|
63
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("hasVoiceInputPermission");
|
|
64
|
-
auto __result = method(_javaPart);
|
|
65
|
-
return static_cast<bool>(__result);
|
|
66
|
-
}
|
|
67
|
-
std::shared_ptr<Promise<bool>> JHybridVoiceSpec::requestVoiceInputPermission() {
|
|
68
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestVoiceInputPermission");
|
|
69
|
-
auto __result = method(_javaPart);
|
|
70
|
-
return [&]() {
|
|
71
|
-
auto __promise = Promise<bool>::create();
|
|
72
|
-
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
73
|
-
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
74
|
-
__promise->resolve(static_cast<bool>(__result->value()));
|
|
75
|
-
});
|
|
76
|
-
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
77
|
-
jni::JniException __jniError(__throwable);
|
|
78
|
-
__promise->reject(std::make_exception_ptr(__jniError));
|
|
79
|
-
});
|
|
80
|
-
return __promise;
|
|
81
|
-
}();
|
|
82
|
-
}
|
|
83
|
-
std::shared_ptr<Promise<VoiceInputResult>> JHybridVoiceSpec::startVoiceInput(std::optional<double> silenceThresholdMs, std::optional<double> maxDurationMs, const std::optional<std::string>& listeningText, std::optional<bool> preferSpeechToText, const std::optional<std::function<void(const VoiceInputChunk& /* chunk */)>>& onChunk) {
|
|
84
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JDouble> /* silenceThresholdMs */, jni::alias_ref<jni::JDouble> /* maxDurationMs */, jni::alias_ref<jni::JString> /* listeningText */, jni::alias_ref<jni::JBoolean> /* preferSpeechToText */, jni::alias_ref<JFunc_void_VoiceInputChunk::javaobject> /* onChunk */)>("startVoiceInput_cxx");
|
|
85
|
-
auto __result = method(_javaPart, silenceThresholdMs.has_value() ? jni::JDouble::valueOf(silenceThresholdMs.value()) : nullptr, maxDurationMs.has_value() ? jni::JDouble::valueOf(maxDurationMs.value()) : nullptr, listeningText.has_value() ? jni::make_jstring(listeningText.value()) : nullptr, preferSpeechToText.has_value() ? jni::JBoolean::valueOf(preferSpeechToText.value()) : nullptr, onChunk.has_value() ? JFunc_void_VoiceInputChunk_cxx::fromCpp(onChunk.value()) : nullptr);
|
|
86
|
-
return [&]() {
|
|
87
|
-
auto __promise = Promise<VoiceInputResult>::create();
|
|
88
|
-
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
89
|
-
auto __result = jni::static_ref_cast<JVoiceInputResult>(__boxedResult);
|
|
90
|
-
__promise->resolve(__result->toCpp());
|
|
91
|
-
});
|
|
92
|
-
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
93
|
-
jni::JniException __jniError(__throwable);
|
|
94
|
-
__promise->reject(std::make_exception_ptr(__jniError));
|
|
95
|
-
});
|
|
96
|
-
return __promise;
|
|
97
|
-
}();
|
|
98
|
-
}
|
|
99
|
-
void JHybridVoiceSpec::stopVoiceInput() {
|
|
100
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopVoiceInput");
|
|
101
|
-
method(_javaPart);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridVoiceSpec.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
|
-
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
-
#include <fbjni/fbjni.h>
|
|
12
|
-
#include "HybridVoiceSpec.hpp"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
18
|
-
|
|
19
|
-
using namespace facebook;
|
|
20
|
-
|
|
21
|
-
class JHybridVoiceSpec: public virtual HybridVoiceSpec, public virtual JHybridObject {
|
|
22
|
-
public:
|
|
23
|
-
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec;";
|
|
25
|
-
std::shared_ptr<JHybridVoiceSpec> getJHybridVoiceSpec();
|
|
26
|
-
};
|
|
27
|
-
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec$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
|
-
};
|
|
35
|
-
|
|
36
|
-
public:
|
|
37
|
-
explicit JHybridVoiceSpec(const jni::local_ref<JHybridVoiceSpec::JavaPart>& javaPart):
|
|
38
|
-
HybridObject(HybridVoiceSpec::TAG),
|
|
39
|
-
JHybridObject(javaPart),
|
|
40
|
-
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
-
~JHybridVoiceSpec() override {
|
|
42
|
-
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
43
|
-
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public:
|
|
47
|
-
inline const jni::global_ref<JHybridVoiceSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
-
return _javaPart;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public:
|
|
52
|
-
// Properties
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
public:
|
|
56
|
-
// Methods
|
|
57
|
-
bool hasVoiceInputPermission() override;
|
|
58
|
-
std::shared_ptr<Promise<bool>> requestVoiceInputPermission() override;
|
|
59
|
-
std::shared_ptr<Promise<VoiceInputResult>> startVoiceInput(std::optional<double> silenceThresholdMs, std::optional<double> maxDurationMs, const std::optional<std::string>& listeningText, std::optional<bool> preferSpeechToText, const std::optional<std::function<void(const VoiceInputChunk& /* chunk */)>>& onChunk) override;
|
|
60
|
-
void stopVoiceInput() override;
|
|
61
|
-
|
|
62
|
-
private:
|
|
63
|
-
jni::global_ref<JHybridVoiceSpec::JavaPart> _javaPart;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// JVoiceInputChunk.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
|
-
#include <fbjni/fbjni.h>
|
|
11
|
-
#include "VoiceInputChunk.hpp"
|
|
12
|
-
|
|
13
|
-
#include <NitroModules/ArrayBuffer.hpp>
|
|
14
|
-
#include <NitroModules/JArrayBuffer.hpp>
|
|
15
|
-
#include <optional>
|
|
16
|
-
#include <string>
|
|
17
|
-
|
|
18
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
19
|
-
|
|
20
|
-
using namespace facebook;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The C++ JNI bridge between the C++ struct "VoiceInputChunk" and the the Kotlin data class "VoiceInputChunk".
|
|
24
|
-
*/
|
|
25
|
-
struct JVoiceInputChunk final: public jni::JavaClass<JVoiceInputChunk> {
|
|
26
|
-
public:
|
|
27
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputChunk;";
|
|
28
|
-
|
|
29
|
-
public:
|
|
30
|
-
/**
|
|
31
|
-
* Convert this Java/Kotlin-based struct to the C++ struct VoiceInputChunk by copying all values to C++.
|
|
32
|
-
*/
|
|
33
|
-
[[maybe_unused]]
|
|
34
|
-
[[nodiscard]]
|
|
35
|
-
VoiceInputChunk toCpp() const {
|
|
36
|
-
static const auto clazz = javaClassStatic();
|
|
37
|
-
static const auto fieldPartial = clazz->getField<jni::JString>("partial");
|
|
38
|
-
jni::local_ref<jni::JString> partial = this->getFieldValue(fieldPartial);
|
|
39
|
-
static const auto fieldAudio = clazz->getField<JArrayBuffer::javaobject>("audio");
|
|
40
|
-
jni::local_ref<JArrayBuffer::javaobject> audio = this->getFieldValue(fieldAudio);
|
|
41
|
-
return VoiceInputChunk(
|
|
42
|
-
partial != nullptr ? std::make_optional(partial->toStdString()) : std::nullopt,
|
|
43
|
-
audio != nullptr ? std::make_optional(audio->cthis()->getArrayBuffer()) : std::nullopt
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public:
|
|
48
|
-
/**
|
|
49
|
-
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
50
|
-
*/
|
|
51
|
-
[[maybe_unused]]
|
|
52
|
-
static jni::local_ref<JVoiceInputChunk::javaobject> fromCpp(const VoiceInputChunk& value) {
|
|
53
|
-
using JSignature = JVoiceInputChunk(jni::alias_ref<jni::JString>, jni::alias_ref<JArrayBuffer::javaobject>);
|
|
54
|
-
static const auto clazz = javaClassStatic();
|
|
55
|
-
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
56
|
-
return create(
|
|
57
|
-
clazz,
|
|
58
|
-
value.partial.has_value() ? jni::make_jstring(value.partial.value()) : nullptr,
|
|
59
|
-
value.audio.has_value() ? JArrayBuffer::wrap(value.audio.value()) : nullptr
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// JVoiceInputResult.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
|
-
#include <fbjni/fbjni.h>
|
|
11
|
-
#include "VoiceInputResult.hpp"
|
|
12
|
-
|
|
13
|
-
#include <NitroModules/ArrayBuffer.hpp>
|
|
14
|
-
#include <NitroModules/JArrayBuffer.hpp>
|
|
15
|
-
#include <optional>
|
|
16
|
-
#include <string>
|
|
17
|
-
|
|
18
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
19
|
-
|
|
20
|
-
using namespace facebook;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The C++ JNI bridge between the C++ struct "VoiceInputResult" and the the Kotlin data class "VoiceInputResult".
|
|
24
|
-
*/
|
|
25
|
-
struct JVoiceInputResult final: public jni::JavaClass<JVoiceInputResult> {
|
|
26
|
-
public:
|
|
27
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputResult;";
|
|
28
|
-
|
|
29
|
-
public:
|
|
30
|
-
/**
|
|
31
|
-
* Convert this Java/Kotlin-based struct to the C++ struct VoiceInputResult by copying all values to C++.
|
|
32
|
-
*/
|
|
33
|
-
[[maybe_unused]]
|
|
34
|
-
[[nodiscard]]
|
|
35
|
-
VoiceInputResult toCpp() const {
|
|
36
|
-
static const auto clazz = javaClassStatic();
|
|
37
|
-
static const auto fieldTranscription = clazz->getField<jni::JString>("transcription");
|
|
38
|
-
jni::local_ref<jni::JString> transcription = this->getFieldValue(fieldTranscription);
|
|
39
|
-
static const auto fieldAudio = clazz->getField<JArrayBuffer::javaobject>("audio");
|
|
40
|
-
jni::local_ref<JArrayBuffer::javaobject> audio = this->getFieldValue(fieldAudio);
|
|
41
|
-
return VoiceInputResult(
|
|
42
|
-
transcription != nullptr ? std::make_optional(transcription->toStdString()) : std::nullopt,
|
|
43
|
-
audio != nullptr ? std::make_optional(audio->cthis()->getArrayBuffer()) : std::nullopt
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public:
|
|
48
|
-
/**
|
|
49
|
-
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
50
|
-
*/
|
|
51
|
-
[[maybe_unused]]
|
|
52
|
-
static jni::local_ref<JVoiceInputResult::javaobject> fromCpp(const VoiceInputResult& value) {
|
|
53
|
-
using JSignature = JVoiceInputResult(jni::alias_ref<jni::JString>, jni::alias_ref<JArrayBuffer::javaobject>);
|
|
54
|
-
static const auto clazz = javaClassStatic();
|
|
55
|
-
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
56
|
-
return create(
|
|
57
|
-
clazz,
|
|
58
|
-
value.transcription.has_value() ? jni::make_jstring(value.transcription.value()) : nullptr,
|
|
59
|
-
value.audio.has_value() ? JArrayBuffer::wrap(value.audio.value()) : nullptr
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Func_void_VoiceInputChunk.kt
|
|
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
|
-
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
9
|
-
|
|
10
|
-
import androidx.annotation.Keep
|
|
11
|
-
import com.facebook.jni.HybridData
|
|
12
|
-
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
-
import dalvik.annotation.optimization.FastNative
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Represents the JavaScript callback `(chunk: struct) => void`.
|
|
18
|
-
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
-
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
-
*/
|
|
21
|
-
@DoNotStrip
|
|
22
|
-
@Keep
|
|
23
|
-
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
-
fun interface Func_void_VoiceInputChunk: (VoiceInputChunk) -> Unit {
|
|
25
|
-
/**
|
|
26
|
-
* Call the given JS callback.
|
|
27
|
-
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
-
*/
|
|
29
|
-
@DoNotStrip
|
|
30
|
-
@Keep
|
|
31
|
-
override fun invoke(chunk: VoiceInputChunk): Unit
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Represents the JavaScript callback `(chunk: struct) => void`.
|
|
36
|
-
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
-
* The callback might be coming from JS.
|
|
38
|
-
*/
|
|
39
|
-
@DoNotStrip
|
|
40
|
-
@Keep
|
|
41
|
-
@Suppress(
|
|
42
|
-
"KotlinJniMissingFunction", "unused",
|
|
43
|
-
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
-
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
-
)
|
|
46
|
-
class Func_void_VoiceInputChunk_cxx: Func_void_VoiceInputChunk {
|
|
47
|
-
@DoNotStrip
|
|
48
|
-
@Keep
|
|
49
|
-
private val mHybridData: HybridData
|
|
50
|
-
|
|
51
|
-
@DoNotStrip
|
|
52
|
-
@Keep
|
|
53
|
-
private constructor(hybridData: HybridData) {
|
|
54
|
-
mHybridData = hybridData
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@DoNotStrip
|
|
58
|
-
@Keep
|
|
59
|
-
override fun invoke(chunk: VoiceInputChunk): Unit
|
|
60
|
-
= invoke_cxx(chunk)
|
|
61
|
-
|
|
62
|
-
@FastNative
|
|
63
|
-
private external fun invoke_cxx(chunk: VoiceInputChunk): Unit
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Represents the JavaScript callback `(chunk: struct) => void`.
|
|
68
|
-
* This is implemented in Java/Kotlin, via a `(VoiceInputChunk) -> Unit`.
|
|
69
|
-
* The callback is always coming from native.
|
|
70
|
-
*/
|
|
71
|
-
@DoNotStrip
|
|
72
|
-
@Keep
|
|
73
|
-
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
-
class Func_void_VoiceInputChunk_java(private val function: (VoiceInputChunk) -> Unit): Func_void_VoiceInputChunk {
|
|
75
|
-
@DoNotStrip
|
|
76
|
-
@Keep
|
|
77
|
-
override fun invoke(chunk: VoiceInputChunk): Unit {
|
|
78
|
-
return this.function(chunk)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridVoiceSpec.kt
|
|
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
|
-
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
9
|
-
|
|
10
|
-
import androidx.annotation.Keep
|
|
11
|
-
import com.facebook.jni.HybridData
|
|
12
|
-
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
-
import com.margelo.nitro.core.Promise
|
|
14
|
-
import com.margelo.nitro.core.HybridObject
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A Kotlin class representing the Voice HybridObject.
|
|
18
|
-
* Implement this abstract class to create Kotlin-based instances of Voice.
|
|
19
|
-
*/
|
|
20
|
-
@DoNotStrip
|
|
21
|
-
@Keep
|
|
22
|
-
@Suppress(
|
|
23
|
-
"KotlinJniMissingFunction", "unused",
|
|
24
|
-
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
25
|
-
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
26
|
-
)
|
|
27
|
-
abstract class HybridVoiceSpec: HybridObject() {
|
|
28
|
-
// Properties
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// Methods
|
|
32
|
-
@DoNotStrip
|
|
33
|
-
@Keep
|
|
34
|
-
abstract fun hasVoiceInputPermission(): Boolean
|
|
35
|
-
|
|
36
|
-
@DoNotStrip
|
|
37
|
-
@Keep
|
|
38
|
-
abstract fun requestVoiceInputPermission(): Promise<Boolean>
|
|
39
|
-
|
|
40
|
-
abstract fun startVoiceInput(silenceThresholdMs: Double?, maxDurationMs: Double?, listeningText: String?, preferSpeechToText: Boolean?, onChunk: ((chunk: VoiceInputChunk) -> Unit)?): Promise<VoiceInputResult>
|
|
41
|
-
|
|
42
|
-
@DoNotStrip
|
|
43
|
-
@Keep
|
|
44
|
-
private fun startVoiceInput_cxx(silenceThresholdMs: Double?, maxDurationMs: Double?, listeningText: String?, preferSpeechToText: Boolean?, onChunk: Func_void_VoiceInputChunk?): Promise<VoiceInputResult> {
|
|
45
|
-
val __result = startVoiceInput(silenceThresholdMs, maxDurationMs, listeningText, preferSpeechToText, onChunk?.let { it })
|
|
46
|
-
return __result
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@DoNotStrip
|
|
50
|
-
@Keep
|
|
51
|
-
abstract fun stopVoiceInput(): Unit
|
|
52
|
-
|
|
53
|
-
// Default implementation of `HybridObject.toString()`
|
|
54
|
-
override fun toString(): String {
|
|
55
|
-
return "[HybridObject Voice]"
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// C++ backing class
|
|
59
|
-
@DoNotStrip
|
|
60
|
-
@Keep
|
|
61
|
-
protected open class CxxPart(javaPart: HybridVoiceSpec): HybridObject.CxxPart(javaPart) {
|
|
62
|
-
// C++ JHybridVoiceSpec::CxxPart::initHybrid(...)
|
|
63
|
-
external override fun initHybrid(): HybridData
|
|
64
|
-
}
|
|
65
|
-
override fun createCxxPart(): CxxPart {
|
|
66
|
-
return CxxPart(this)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
companion object {
|
|
70
|
-
protected const val TAG = "HybridVoiceSpec"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// VoiceInputChunk.kt
|
|
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
|
-
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
9
|
-
|
|
10
|
-
import androidx.annotation.Keep
|
|
11
|
-
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
-
import com.margelo.nitro.core.ArrayBuffer
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Represents the JavaScript object/struct "VoiceInputChunk".
|
|
16
|
-
*/
|
|
17
|
-
@DoNotStrip
|
|
18
|
-
@Keep
|
|
19
|
-
data class VoiceInputChunk(
|
|
20
|
-
@DoNotStrip
|
|
21
|
-
@Keep
|
|
22
|
-
val partial: String?,
|
|
23
|
-
@DoNotStrip
|
|
24
|
-
@Keep
|
|
25
|
-
val audio: ArrayBuffer?
|
|
26
|
-
) {
|
|
27
|
-
/* primary constructor */
|
|
28
|
-
|
|
29
|
-
companion object {
|
|
30
|
-
/**
|
|
31
|
-
* Constructor called from C++
|
|
32
|
-
*/
|
|
33
|
-
@DoNotStrip
|
|
34
|
-
@Keep
|
|
35
|
-
@Suppress("unused")
|
|
36
|
-
@JvmStatic
|
|
37
|
-
private fun fromCpp(partial: String?, audio: ArrayBuffer?): VoiceInputChunk {
|
|
38
|
-
return VoiceInputChunk(partial, audio)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// VoiceInputResult.kt
|
|
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
|
-
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
9
|
-
|
|
10
|
-
import androidx.annotation.Keep
|
|
11
|
-
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
-
import com.margelo.nitro.core.ArrayBuffer
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Represents the JavaScript object/struct "VoiceInputResult".
|
|
16
|
-
*/
|
|
17
|
-
@DoNotStrip
|
|
18
|
-
@Keep
|
|
19
|
-
data class VoiceInputResult(
|
|
20
|
-
@DoNotStrip
|
|
21
|
-
@Keep
|
|
22
|
-
val transcription: String?,
|
|
23
|
-
@DoNotStrip
|
|
24
|
-
@Keep
|
|
25
|
-
val audio: ArrayBuffer?
|
|
26
|
-
) {
|
|
27
|
-
/* primary constructor */
|
|
28
|
-
|
|
29
|
-
companion object {
|
|
30
|
-
/**
|
|
31
|
-
* Constructor called from C++
|
|
32
|
-
*/
|
|
33
|
-
@DoNotStrip
|
|
34
|
-
@Keep
|
|
35
|
-
@Suppress("unused")
|
|
36
|
-
@JvmStatic
|
|
37
|
-
private fun fromCpp(transcription: String?, audio: ArrayBuffer?): VoiceInputResult {
|
|
38
|
-
return VoiceInputResult(transcription, audio)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridVoiceSpecSwift.cpp
|
|
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
|
-
#include "HybridVoiceSpecSwift.hpp"
|
|
9
|
-
|
|
10
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
11
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridVoiceSpecSwift.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
|
-
#include "HybridVoiceSpec.hpp"
|
|
11
|
-
|
|
12
|
-
// Forward declaration of `HybridVoiceSpec_cxx` to properly resolve imports.
|
|
13
|
-
namespace ReactNativeAutoPlay { class HybridVoiceSpec_cxx; }
|
|
14
|
-
|
|
15
|
-
// Forward declaration of `VoiceInputResult` to properly resolve imports.
|
|
16
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct VoiceInputResult; }
|
|
17
|
-
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
18
|
-
namespace NitroModules { class ArrayBufferHolder; }
|
|
19
|
-
// Forward declaration of `VoiceInputChunk` to properly resolve imports.
|
|
20
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct VoiceInputChunk; }
|
|
21
|
-
|
|
22
|
-
#include <NitroModules/Promise.hpp>
|
|
23
|
-
#include "VoiceInputResult.hpp"
|
|
24
|
-
#include <string>
|
|
25
|
-
#include <optional>
|
|
26
|
-
#include <NitroModules/ArrayBuffer.hpp>
|
|
27
|
-
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
28
|
-
#include "VoiceInputChunk.hpp"
|
|
29
|
-
#include <functional>
|
|
30
|
-
|
|
31
|
-
#include "ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp"
|
|
32
|
-
|
|
33
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The C++ part of HybridVoiceSpec_cxx.swift.
|
|
37
|
-
*
|
|
38
|
-
* HybridVoiceSpecSwift (C++) accesses HybridVoiceSpec_cxx (Swift), and might
|
|
39
|
-
* contain some additional bridging code for C++ <> Swift interop.
|
|
40
|
-
*
|
|
41
|
-
* Since this obviously introduces an overhead, I hope at some point in
|
|
42
|
-
* the future, HybridVoiceSpec_cxx can directly inherit from the C++ class HybridVoiceSpec
|
|
43
|
-
* to simplify the whole structure and memory management.
|
|
44
|
-
*/
|
|
45
|
-
class HybridVoiceSpecSwift: public virtual HybridVoiceSpec {
|
|
46
|
-
public:
|
|
47
|
-
// Constructor from a Swift instance
|
|
48
|
-
explicit HybridVoiceSpecSwift(const ReactNativeAutoPlay::HybridVoiceSpec_cxx& swiftPart):
|
|
49
|
-
HybridObject(HybridVoiceSpec::TAG),
|
|
50
|
-
_swiftPart(swiftPart) { }
|
|
51
|
-
|
|
52
|
-
public:
|
|
53
|
-
// Get the Swift part
|
|
54
|
-
inline ReactNativeAutoPlay::HybridVoiceSpec_cxx& getSwiftPart() noexcept {
|
|
55
|
-
return _swiftPart;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public:
|
|
59
|
-
inline size_t getExternalMemorySize() noexcept override {
|
|
60
|
-
return _swiftPart.getMemorySize();
|
|
61
|
-
}
|
|
62
|
-
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
63
|
-
if (auto otherCast = std::dynamic_pointer_cast<HybridVoiceSpecSwift>(other)) {
|
|
64
|
-
return _swiftPart.equals(otherCast->_swiftPart);
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
void dispose() noexcept override {
|
|
69
|
-
_swiftPart.dispose();
|
|
70
|
-
}
|
|
71
|
-
std::string toString() override {
|
|
72
|
-
return _swiftPart.toString();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public:
|
|
76
|
-
// Properties
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
public:
|
|
80
|
-
// Methods
|
|
81
|
-
inline bool hasVoiceInputPermission() override {
|
|
82
|
-
auto __result = _swiftPart.hasVoiceInputPermission();
|
|
83
|
-
if (__result.hasError()) [[unlikely]] {
|
|
84
|
-
std::rethrow_exception(__result.error());
|
|
85
|
-
}
|
|
86
|
-
auto __value = std::move(__result.value());
|
|
87
|
-
return __value;
|
|
88
|
-
}
|
|
89
|
-
inline std::shared_ptr<Promise<bool>> requestVoiceInputPermission() override {
|
|
90
|
-
auto __result = _swiftPart.requestVoiceInputPermission();
|
|
91
|
-
if (__result.hasError()) [[unlikely]] {
|
|
92
|
-
std::rethrow_exception(__result.error());
|
|
93
|
-
}
|
|
94
|
-
auto __value = std::move(__result.value());
|
|
95
|
-
return __value;
|
|
96
|
-
}
|
|
97
|
-
inline std::shared_ptr<Promise<VoiceInputResult>> startVoiceInput(std::optional<double> silenceThresholdMs, std::optional<double> maxDurationMs, const std::optional<std::string>& listeningText, std::optional<bool> preferSpeechToText, const std::optional<std::function<void(const VoiceInputChunk& /* chunk */)>>& onChunk) override {
|
|
98
|
-
auto __result = _swiftPart.startVoiceInput(silenceThresholdMs, maxDurationMs, listeningText, preferSpeechToText, onChunk);
|
|
99
|
-
if (__result.hasError()) [[unlikely]] {
|
|
100
|
-
std::rethrow_exception(__result.error());
|
|
101
|
-
}
|
|
102
|
-
auto __value = std::move(__result.value());
|
|
103
|
-
return __value;
|
|
104
|
-
}
|
|
105
|
-
inline void stopVoiceInput() override {
|
|
106
|
-
auto __result = _swiftPart.stopVoiceInput();
|
|
107
|
-
if (__result.hasError()) [[unlikely]] {
|
|
108
|
-
std::rethrow_exception(__result.error());
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private:
|
|
113
|
-
ReactNativeAutoPlay::HybridVoiceSpec_cxx _swiftPart;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|