74808f086e
* feat: Replace Legacy Media Controls with Nitro-Powered Playback * feat: Add TTS Engine Selection * chore: Remove User-Facing Error Reporting * refactor: Combine `Tts` and `TtsSession` Imports from `nitro-tts` Module --------- Co-authored-by: Claude <noreply@anthropic.com>
242 lines
12 KiB
C++
Generated
242 lines
12 KiB
C++
Generated
///
|
|
/// JHybridTtsSessionSpec.cpp
|
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
/// https://github.com/mrousavy/nitro
|
|
/// Copyright © Marc Rousavy @ Margelo
|
|
///
|
|
|
|
#include "JHybridTtsSessionSpec.hpp"
|
|
|
|
// Forward declaration of `ListenerSubscription` to properly resolve imports.
|
|
namespace margelo::nitro::nitrotts { struct ListenerSubscription; }
|
|
// Forward declaration of `TtsParagraph` to properly resolve imports.
|
|
namespace margelo::nitro::nitrotts { struct TtsParagraph; }
|
|
// Forward declaration of `TtsMetadata` to properly resolve imports.
|
|
namespace margelo::nitro::nitrotts { struct TtsMetadata; }
|
|
// Forward declaration of `TtsSettings` to properly resolve imports.
|
|
namespace margelo::nitro::nitrotts { struct TtsSettings; }
|
|
// Forward declaration of `TtsPlaybackState` to properly resolve imports.
|
|
namespace margelo::nitro::nitrotts { enum class TtsPlaybackState; }
|
|
// Forward declaration of `TtsProgress` to properly resolve imports.
|
|
namespace margelo::nitro::nitrotts { struct TtsProgress; }
|
|
|
|
#include <NitroModules/Promise.hpp>
|
|
#include <NitroModules/JPromise.hpp>
|
|
#include <NitroModules/JUnit.hpp>
|
|
#include "ListenerSubscription.hpp"
|
|
#include "JListenerSubscription.hpp"
|
|
#include <functional>
|
|
#include "JFunc_void.hpp"
|
|
#include <NitroModules/JNICallable.hpp>
|
|
#include "TtsParagraph.hpp"
|
|
#include <vector>
|
|
#include "JTtsParagraph.hpp"
|
|
#include <string>
|
|
#include "TtsMetadata.hpp"
|
|
#include "JTtsMetadata.hpp"
|
|
#include <optional>
|
|
#include "TtsSettings.hpp"
|
|
#include "JTtsSettings.hpp"
|
|
#include "TtsPlaybackState.hpp"
|
|
#include "JFunc_void_TtsPlaybackState.hpp"
|
|
#include "JTtsPlaybackState.hpp"
|
|
#include "TtsProgress.hpp"
|
|
#include "JFunc_void_TtsProgress.hpp"
|
|
#include "JTtsProgress.hpp"
|
|
#include "JFunc_void_std__string.hpp"
|
|
|
|
namespace margelo::nitro::nitrotts {
|
|
|
|
std::shared_ptr<JHybridTtsSessionSpec> JHybridTtsSessionSpec::JavaPart::getJHybridTtsSessionSpec() {
|
|
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
auto castHybridObject = std::dynamic_pointer_cast<JHybridTtsSessionSpec>(hybridObject);
|
|
if (castHybridObject == nullptr) [[unlikely]] {
|
|
throw std::runtime_error("Failed to downcast JHybridObject to JHybridTtsSessionSpec!");
|
|
}
|
|
return castHybridObject;
|
|
}
|
|
|
|
jni::local_ref<JHybridTtsSessionSpec::CxxPart::jhybriddata> JHybridTtsSessionSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
return makeCxxInstance(jThis);
|
|
}
|
|
|
|
std::shared_ptr<JHybridObject> JHybridTtsSessionSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
auto castJavaPart = jni::dynamic_ref_cast<JHybridTtsSessionSpec::JavaPart>(javaPart);
|
|
if (castJavaPart == nullptr) [[unlikely]] {
|
|
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridTtsSessionSpec::JavaPart!");
|
|
}
|
|
return std::make_shared<JHybridTtsSessionSpec>(castJavaPart);
|
|
}
|
|
|
|
void JHybridTtsSessionSpec::CxxPart::registerNatives() {
|
|
registerHybrid({
|
|
makeNativeMethod("initHybrid", JHybridTtsSessionSpec::CxxPart::initHybrid),
|
|
});
|
|
}
|
|
|
|
// Properties
|
|
|
|
|
|
// Methods
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::load(const std::vector<TtsParagraph>& paragraphs, double initialIndex, const TtsMetadata& metadata, const TtsSettings& settings) {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JArrayClass<JTtsParagraph>> /* paragraphs */, double /* initialIndex */, jni::alias_ref<JTtsMetadata> /* metadata */, jni::alias_ref<JTtsSettings> /* settings */)>("load");
|
|
auto __result = method(_javaPart, [&](auto&& __input) {
|
|
size_t __size = __input.size();
|
|
jni::local_ref<jni::JArrayClass<JTtsParagraph>> __array = jni::JArrayClass<JTtsParagraph>::newArray(__size);
|
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
const auto& __element = __input[__i];
|
|
auto __elementJni = JTtsParagraph::fromCpp(__element);
|
|
__array->setElement(__i, *__elementJni);
|
|
}
|
|
return __array;
|
|
}(paragraphs), initialIndex, JTtsMetadata::fromCpp(metadata), JTtsSettings::fromCpp(settings));
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::play() {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("play");
|
|
auto __result = method(_javaPart);
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::pause() {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("pause");
|
|
auto __result = method(_javaPart);
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::stop() {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("stop");
|
|
auto __result = method(_javaPart);
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::skipPrevious() {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("skipPrevious");
|
|
auto __result = method(_javaPart);
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::skipNext() {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("skipNext");
|
|
auto __result = method(_javaPart);
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::replayCurrent() {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("replayCurrent");
|
|
auto __result = method(_javaPart);
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::seekTo(double index) {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(double /* index */)>("seekTo");
|
|
auto __result = method(_javaPart, index);
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
std::shared_ptr<Promise<void>> JHybridTtsSessionSpec::updateSettings(const TtsSettings& settings) {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JTtsSettings> /* settings */)>("updateSettings");
|
|
auto __result = method(_javaPart, JTtsSettings::fromCpp(settings));
|
|
return [&]() {
|
|
auto __promise = Promise<void>::create();
|
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
__promise->resolve();
|
|
});
|
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
jni::JniException __jniError(__throwable);
|
|
__promise->reject(std::make_exception_ptr(__jniError));
|
|
});
|
|
return __promise;
|
|
}();
|
|
}
|
|
ListenerSubscription JHybridTtsSessionSpec::addOnStateChangedListener(const std::function<void(TtsPlaybackState /* state */)>& listener) {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JListenerSubscription>(jni::alias_ref<JFunc_void_TtsPlaybackState::javaobject> /* listener */)>("addOnStateChangedListener_cxx");
|
|
auto __result = method(_javaPart, JFunc_void_TtsPlaybackState_cxx::fromCpp(listener));
|
|
return __result->toCpp();
|
|
}
|
|
ListenerSubscription JHybridTtsSessionSpec::addOnProgressChangedListener(const std::function<void(const TtsProgress& /* progress */)>& listener) {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JListenerSubscription>(jni::alias_ref<JFunc_void_TtsProgress::javaobject> /* listener */)>("addOnProgressChangedListener_cxx");
|
|
auto __result = method(_javaPart, JFunc_void_TtsProgress_cxx::fromCpp(listener));
|
|
return __result->toCpp();
|
|
}
|
|
ListenerSubscription JHybridTtsSessionSpec::addOnErrorListener(const std::function<void(const std::string& /* message */)>& listener) {
|
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JListenerSubscription>(jni::alias_ref<JFunc_void_std__string::javaobject> /* listener */)>("addOnErrorListener_cxx");
|
|
auto __result = method(_javaPart, JFunc_void_std__string_cxx::fromCpp(listener));
|
|
return __result->toCpp();
|
|
}
|
|
|
|
} // namespace margelo::nitro::nitrotts
|