Files
Rajarshee Chatterjee 74808f086e feat: Replace Legacy Media Controls with Nitro-Powered Playback (#1896)
* 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>
2026-07-24 23:42:17 +05:30

97 lines
4.2 KiB
C++
Generated

///
/// TtsSettings.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#pragma once
#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#include <string>
#include <optional>
namespace margelo::nitro::nitrotts {
/**
* A struct which can be represented as a JavaScript object (TtsSettings).
*/
struct TtsSettings final {
public:
std::optional<std::string> engineName SWIFT_PRIVATE;
std::optional<std::string> voiceIdentifier SWIFT_PRIVATE;
double rate SWIFT_PRIVATE;
double pitch SWIFT_PRIVATE;
public:
TtsSettings() = default;
explicit TtsSettings(std::optional<std::string> engineName, std::optional<std::string> voiceIdentifier, double rate, double pitch): engineName(engineName), voiceIdentifier(voiceIdentifier), rate(rate), pitch(pitch) {}
public:
friend bool operator==(const TtsSettings& lhs, const TtsSettings& rhs) = default;
};
} // namespace margelo::nitro::nitrotts
namespace margelo::nitro {
// C++ TtsSettings <> JS TtsSettings (object)
template <>
struct JSIConverter<margelo::nitro::nitrotts::TtsSettings> final {
static inline margelo::nitro::nitrotts::TtsSettings fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
jsi::Object obj = arg.asObject(runtime);
return margelo::nitro::nitrotts::TtsSettings(
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "engineName"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "voiceIdentifier"))),
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rate"))),
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pitch")))
);
}
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrotts::TtsSettings& arg) {
jsi::Object obj(runtime);
obj.setProperty(runtime, PropNameIDCache::get(runtime, "engineName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.engineName));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "voiceIdentifier"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.voiceIdentifier));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "rate"), JSIConverter<double>::toJSI(runtime, arg.rate));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "pitch"), JSIConverter<double>::toJSI(runtime, arg.pitch));
return obj;
}
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
if (!value.isObject()) {
return false;
}
jsi::Object obj = value.getObject(runtime);
if (!nitro::isPlainObject(runtime, obj)) {
return false;
}
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "engineName")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "voiceIdentifier")))) return false;
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rate")))) return false;
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pitch")))) return false;
return true;
}
};
} // namespace margelo::nitro