react-native-nitro-onnx 0.1.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.
Files changed (91) hide show
  1. package/NOTICE +241 -0
  2. package/NitroOnnxSpeech.podspec +51 -0
  3. package/Package.swift +52 -0
  4. package/README.md +398 -0
  5. package/android/CMakeLists.txt +117 -0
  6. package/android/build.gradle +65 -0
  7. package/android/src/main/AndroidManifest.xml +6 -0
  8. package/android/src/main/assets/silero_vad.onnx +0 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +24 -0
  10. package/android/src/main/java/com/margelo/nitro/onnx/speech/OnnxSpeechPackage.kt +67 -0
  11. package/assets/silero_vad.onnx +0 -0
  12. package/cpp/AndroidPthreadCompat.cpp +16 -0
  13. package/cpp/AsrEngine.cpp +277 -0
  14. package/cpp/AsrEngine.hpp +110 -0
  15. package/cpp/AudioFileReader.cpp +177 -0
  16. package/cpp/AudioFileReader.hpp +26 -0
  17. package/cpp/AudioUtils.cpp +28 -0
  18. package/cpp/AudioUtils.hpp +38 -0
  19. package/cpp/ModelSingleton.hpp +51 -0
  20. package/cpp/NitroOnnxSpeech.cpp +68 -0
  21. package/cpp/NitroOnnxSpeech.hpp +42 -0
  22. package/cpp/OfflineAsr.cpp +81 -0
  23. package/cpp/OfflineAsr.hpp +33 -0
  24. package/cpp/ResourceDir.cpp +29 -0
  25. package/cpp/ResourceDir.hpp +18 -0
  26. package/cpp/SpeakerEngine.cpp +170 -0
  27. package/cpp/SpeakerEngine.hpp +70 -0
  28. package/cpp/SpeakerManager.cpp +93 -0
  29. package/cpp/SpeakerManager.hpp +43 -0
  30. package/cpp/StreamingAsr.cpp +123 -0
  31. package/cpp/StreamingAsr.hpp +55 -0
  32. package/cpp/ThreadPool.cpp +41 -0
  33. package/cpp/ThreadPool.hpp +62 -0
  34. package/cpp/Tts.cpp +132 -0
  35. package/cpp/Tts.hpp +38 -0
  36. package/cpp/TtsEngine.cpp +222 -0
  37. package/cpp/TtsEngine.hpp +77 -0
  38. package/cpp/Vad.cpp +126 -0
  39. package/cpp/Vad.hpp +62 -0
  40. package/cpp/VadEngine.cpp +217 -0
  41. package/cpp/VadEngine.hpp +126 -0
  42. package/ios/OnnxSpeechInitializer.mm +37 -0
  43. package/ios/PrivacyInfo.xcprivacy +14 -0
  44. package/lib/index.d.ts +11 -0
  45. package/lib/index.d.ts.map +1 -0
  46. package/lib/index.js +19 -0
  47. package/lib/index.js.map +1 -0
  48. package/lib/specs/OnnxSpeech.nitro.d.ts +264 -0
  49. package/lib/specs/OnnxSpeech.nitro.d.ts.map +1 -0
  50. package/lib/specs/OnnxSpeech.nitro.js +6 -0
  51. package/lib/specs/OnnxSpeech.nitro.js.map +1 -0
  52. package/nitro.json +19 -0
  53. package/nitrogen/generated/.gitattributes +1 -0
  54. package/nitrogen/generated/android/NitroOnnxSpeech+autolinking.cmake +86 -0
  55. package/nitrogen/generated/android/NitroOnnxSpeech+autolinking.gradle +27 -0
  56. package/nitrogen/generated/android/NitroOnnxSpeechOnLoad.cpp +49 -0
  57. package/nitrogen/generated/android/NitroOnnxSpeechOnLoad.hpp +34 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/onnx/speech/NitroOnnxSpeechOnLoad.kt +35 -0
  59. package/nitrogen/generated/ios/NitroOnnxSpeech+autolinking.rb +62 -0
  60. package/nitrogen/generated/ios/NitroOnnxSpeech-Swift-Cxx-Bridge.cpp +17 -0
  61. package/nitrogen/generated/ios/NitroOnnxSpeech-Swift-Cxx-Bridge.hpp +27 -0
  62. package/nitrogen/generated/ios/NitroOnnxSpeech-Swift-Cxx-Umbrella.hpp +38 -0
  63. package/nitrogen/generated/ios/NitroOnnxSpeechAutolinking.mm +35 -0
  64. package/nitrogen/generated/ios/NitroOnnxSpeechAutolinking.swift +16 -0
  65. package/nitrogen/generated/shared/c++/AsrModelConfig.hpp +142 -0
  66. package/nitrogen/generated/shared/c++/AsrModelType.hpp +112 -0
  67. package/nitrogen/generated/shared/c++/AsrResult.hpp +105 -0
  68. package/nitrogen/generated/shared/c++/HybridOfflineAsrSpec.cpp +25 -0
  69. package/nitrogen/generated/shared/c++/HybridOfflineAsrSpec.hpp +73 -0
  70. package/nitrogen/generated/shared/c++/HybridOnnxSpeechSpec.cpp +27 -0
  71. package/nitrogen/generated/shared/c++/HybridOnnxSpeechSpec.hpp +82 -0
  72. package/nitrogen/generated/shared/c++/HybridSpeakerManagerSpec.cpp +28 -0
  73. package/nitrogen/generated/shared/c++/HybridSpeakerManagerSpec.hpp +77 -0
  74. package/nitrogen/generated/shared/c++/HybridStreamingAsrSpec.cpp +32 -0
  75. package/nitrogen/generated/shared/c++/HybridStreamingAsrSpec.hpp +81 -0
  76. package/nitrogen/generated/shared/c++/HybridTtsSpec.cpp +26 -0
  77. package/nitrogen/generated/shared/c++/HybridTtsSpec.hpp +74 -0
  78. package/nitrogen/generated/shared/c++/HybridVadSpec.cpp +31 -0
  79. package/nitrogen/generated/shared/c++/HybridVadSpec.hpp +81 -0
  80. package/nitrogen/generated/shared/c++/RegisteredSpeaker.hpp +91 -0
  81. package/nitrogen/generated/shared/c++/SpeakerEmbeddingConfig.hpp +91 -0
  82. package/nitrogen/generated/shared/c++/TtsModelConfig.hpp +178 -0
  83. package/nitrogen/generated/shared/c++/TtsModelType.hpp +88 -0
  84. package/nitrogen/generated/shared/c++/TtsResult.hpp +91 -0
  85. package/nitrogen/generated/shared/c++/VadConfig.hpp +100 -0
  86. package/nitrogen/generated/shared/c++/VadSegment.hpp +91 -0
  87. package/package.json +62 -0
  88. package/scripts/prepare-sherpa-onnx.js +236 -0
  89. package/scripts/test-cpp.js +24 -0
  90. package/src/index.ts +45 -0
  91. package/src/specs/OnnxSpeech.nitro.ts +326 -0
@@ -0,0 +1,81 @@
1
+ ///
2
+ /// HybridVadSpec.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/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `VadSegment` to properly resolve imports.
17
+ namespace margelo::nitro::onnx::speech { struct VadSegment; }
18
+ // Forward declaration of `VadConfig` to properly resolve imports.
19
+ namespace margelo::nitro::onnx::speech { struct VadConfig; }
20
+
21
+ #include "VadSegment.hpp"
22
+ #include <functional>
23
+ #include <optional>
24
+ #include <string>
25
+ #include <NitroModules/Promise.hpp>
26
+ #include "VadConfig.hpp"
27
+ #include <NitroModules/ArrayBuffer.hpp>
28
+ #include <vector>
29
+
30
+ namespace margelo::nitro::onnx::speech {
31
+
32
+ using namespace margelo::nitro;
33
+
34
+ /**
35
+ * An abstract base class for `Vad`
36
+ * Inherit this class to create instances of `HybridVadSpec` in C++.
37
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
38
+ * @example
39
+ * ```cpp
40
+ * class HybridVad: public HybridVadSpec {
41
+ * public:
42
+ * HybridVad(...): HybridObject(TAG) { ... }
43
+ * // ...
44
+ * };
45
+ * ```
46
+ */
47
+ class HybridVadSpec: public virtual HybridObject {
48
+ public:
49
+ // Constructor
50
+ explicit HybridVadSpec(): HybridObject(TAG) { }
51
+
52
+ // Destructor
53
+ ~HybridVadSpec() override = default;
54
+
55
+ public:
56
+ // Properties
57
+ virtual std::optional<std::function<void(const VadSegment& /* segment */)>> getOnSpeechStart() = 0;
58
+ virtual void setOnSpeechStart(const std::optional<std::function<void(const VadSegment& /* segment */)>>& onSpeechStart) = 0;
59
+ virtual std::optional<std::function<void(const VadSegment& /* segment */)>> getOnSpeechEnd() = 0;
60
+ virtual void setOnSpeechEnd(const std::optional<std::function<void(const VadSegment& /* segment */)>>& onSpeechEnd) = 0;
61
+ virtual std::optional<std::function<void(const std::string& /* error */)>> getOnError() = 0;
62
+ virtual void setOnError(const std::optional<std::function<void(const std::string& /* error */)>>& onError) = 0;
63
+
64
+ public:
65
+ // Methods
66
+ virtual std::shared_ptr<Promise<void>> initialize(const VadConfig& config) = 0;
67
+ virtual bool isInitialized() = 0;
68
+ virtual std::shared_ptr<Promise<void>> process(const std::shared_ptr<ArrayBuffer>& samples) = 0;
69
+ virtual std::shared_ptr<Promise<std::vector<VadSegment>>> pullSegments() = 0;
70
+ virtual std::shared_ptr<Promise<void>> reset() = 0;
71
+
72
+ protected:
73
+ // Hybrid Setup
74
+ void loadHybridMethods() override;
75
+
76
+ protected:
77
+ // Tag for logging
78
+ static constexpr auto TAG = "Vad";
79
+ };
80
+
81
+ } // namespace margelo::nitro::onnx::speech
@@ -0,0 +1,91 @@
1
+ ///
2
+ /// RegisteredSpeaker.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
+
32
+
33
+ #include <string>
34
+
35
+ namespace margelo::nitro::onnx::speech {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (RegisteredSpeaker).
39
+ */
40
+ struct RegisteredSpeaker final {
41
+ public:
42
+ std::string id SWIFT_PRIVATE;
43
+ std::string name SWIFT_PRIVATE;
44
+ std::string embeddingPath SWIFT_PRIVATE;
45
+
46
+ public:
47
+ RegisteredSpeaker() = default;
48
+ explicit RegisteredSpeaker(std::string id, std::string name, std::string embeddingPath): id(id), name(name), embeddingPath(embeddingPath) {}
49
+
50
+ public:
51
+ friend bool operator==(const RegisteredSpeaker& lhs, const RegisteredSpeaker& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::onnx::speech
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ RegisteredSpeaker <> JS RegisteredSpeaker (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::onnx::speech::RegisteredSpeaker> final {
61
+ static inline margelo::nitro::onnx::speech::RegisteredSpeaker fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::onnx::speech::RegisteredSpeaker(
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
65
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
66
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "embeddingPath")))
67
+ );
68
+ }
69
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::onnx::speech::RegisteredSpeaker& arg) {
70
+ jsi::Object obj(runtime);
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::string>::toJSI(runtime, arg.id));
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "embeddingPath"), JSIConverter<std::string>::toJSI(runtime, arg.embeddingPath));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
85
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
86
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "embeddingPath")))) return false;
87
+ return true;
88
+ }
89
+ };
90
+
91
+ } // namespace margelo::nitro
@@ -0,0 +1,91 @@
1
+ ///
2
+ /// SpeakerEmbeddingConfig.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
+
32
+
33
+ #include <string>
34
+
35
+ namespace margelo::nitro::onnx::speech {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (SpeakerEmbeddingConfig).
39
+ */
40
+ struct SpeakerEmbeddingConfig final {
41
+ public:
42
+ std::string modelDir SWIFT_PRIVATE;
43
+ std::string model SWIFT_PRIVATE;
44
+ double numThreads SWIFT_PRIVATE;
45
+
46
+ public:
47
+ SpeakerEmbeddingConfig() = default;
48
+ explicit SpeakerEmbeddingConfig(std::string modelDir, std::string model, double numThreads): modelDir(modelDir), model(model), numThreads(numThreads) {}
49
+
50
+ public:
51
+ friend bool operator==(const SpeakerEmbeddingConfig& lhs, const SpeakerEmbeddingConfig& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::onnx::speech
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ SpeakerEmbeddingConfig <> JS SpeakerEmbeddingConfig (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::onnx::speech::SpeakerEmbeddingConfig> final {
61
+ static inline margelo::nitro::onnx::speech::SpeakerEmbeddingConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::onnx::speech::SpeakerEmbeddingConfig(
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modelDir"))),
65
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "model"))),
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "numThreads")))
67
+ );
68
+ }
69
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::onnx::speech::SpeakerEmbeddingConfig& arg) {
70
+ jsi::Object obj(runtime);
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "modelDir"), JSIConverter<std::string>::toJSI(runtime, arg.modelDir));
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "model"), JSIConverter<std::string>::toJSI(runtime, arg.model));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "numThreads"), JSIConverter<double>::toJSI(runtime, arg.numThreads));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modelDir")))) return false;
85
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "model")))) return false;
86
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "numThreads")))) return false;
87
+ return true;
88
+ }
89
+ };
90
+
91
+ } // namespace margelo::nitro
@@ -0,0 +1,178 @@
1
+ ///
2
+ /// TtsModelConfig.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 `TtsModelType` to properly resolve imports.
32
+ namespace margelo::nitro::onnx::speech { enum class TtsModelType; }
33
+
34
+ #include "TtsModelType.hpp"
35
+ #include <string>
36
+ #include <optional>
37
+
38
+ namespace margelo::nitro::onnx::speech {
39
+
40
+ /**
41
+ * A struct which can be represented as a JavaScript object (TtsModelConfig).
42
+ */
43
+ struct TtsModelConfig final {
44
+ public:
45
+ TtsModelType type SWIFT_PRIVATE;
46
+ std::string modelDir SWIFT_PRIVATE;
47
+ std::optional<std::string> model SWIFT_PRIVATE;
48
+ std::optional<std::string> acousticModel SWIFT_PRIVATE;
49
+ std::optional<std::string> vocoder SWIFT_PRIVATE;
50
+ std::optional<std::string> tokens SWIFT_PRIVATE;
51
+ std::optional<std::string> lexicon SWIFT_PRIVATE;
52
+ std::optional<std::string> voices SWIFT_PRIVATE;
53
+ std::optional<std::string> espeakNgData SWIFT_PRIVATE;
54
+ std::optional<std::string> dictDir SWIFT_PRIVATE;
55
+ std::optional<std::string> lmMain SWIFT_PRIVATE;
56
+ std::optional<std::string> lmFlow SWIFT_PRIVATE;
57
+ std::optional<std::string> textConditioner SWIFT_PRIVATE;
58
+ std::optional<std::string> pocketEncoder SWIFT_PRIVATE;
59
+ std::optional<std::string> pocketDecoder SWIFT_PRIVATE;
60
+ std::optional<std::string> vocabJson SWIFT_PRIVATE;
61
+ std::optional<std::string> tokenScoresJson SWIFT_PRIVATE;
62
+ std::optional<std::string> zipvoiceEncoder SWIFT_PRIVATE;
63
+ std::optional<std::string> zipvoiceDecoder SWIFT_PRIVATE;
64
+ std::optional<std::string> config SWIFT_PRIVATE;
65
+ std::optional<double> numThreads SWIFT_PRIVATE;
66
+ std::optional<double> outputSampleRate SWIFT_PRIVATE;
67
+ std::optional<double> speakerId SWIFT_PRIVATE;
68
+ std::optional<double> speed SWIFT_PRIVATE;
69
+
70
+ public:
71
+ TtsModelConfig() = default;
72
+ explicit TtsModelConfig(TtsModelType type, std::string modelDir, std::optional<std::string> model, std::optional<std::string> acousticModel, std::optional<std::string> vocoder, std::optional<std::string> tokens, std::optional<std::string> lexicon, std::optional<std::string> voices, std::optional<std::string> espeakNgData, std::optional<std::string> dictDir, std::optional<std::string> lmMain, std::optional<std::string> lmFlow, std::optional<std::string> textConditioner, std::optional<std::string> pocketEncoder, std::optional<std::string> pocketDecoder, std::optional<std::string> vocabJson, std::optional<std::string> tokenScoresJson, std::optional<std::string> zipvoiceEncoder, std::optional<std::string> zipvoiceDecoder, std::optional<std::string> config, std::optional<double> numThreads, std::optional<double> outputSampleRate, std::optional<double> speakerId, std::optional<double> speed): type(type), modelDir(modelDir), model(model), acousticModel(acousticModel), vocoder(vocoder), tokens(tokens), lexicon(lexicon), voices(voices), espeakNgData(espeakNgData), dictDir(dictDir), lmMain(lmMain), lmFlow(lmFlow), textConditioner(textConditioner), pocketEncoder(pocketEncoder), pocketDecoder(pocketDecoder), vocabJson(vocabJson), tokenScoresJson(tokenScoresJson), zipvoiceEncoder(zipvoiceEncoder), zipvoiceDecoder(zipvoiceDecoder), config(config), numThreads(numThreads), outputSampleRate(outputSampleRate), speakerId(speakerId), speed(speed) {}
73
+
74
+ public:
75
+ friend bool operator==(const TtsModelConfig& lhs, const TtsModelConfig& rhs) = default;
76
+ };
77
+
78
+ } // namespace margelo::nitro::onnx::speech
79
+
80
+ namespace margelo::nitro {
81
+
82
+ // C++ TtsModelConfig <> JS TtsModelConfig (object)
83
+ template <>
84
+ struct JSIConverter<margelo::nitro::onnx::speech::TtsModelConfig> final {
85
+ static inline margelo::nitro::onnx::speech::TtsModelConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
86
+ jsi::Object obj = arg.asObject(runtime);
87
+ return margelo::nitro::onnx::speech::TtsModelConfig(
88
+ JSIConverter<margelo::nitro::onnx::speech::TtsModelType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
89
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modelDir"))),
90
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "model"))),
91
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "acousticModel"))),
92
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vocoder"))),
93
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokens"))),
94
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lexicon"))),
95
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "voices"))),
96
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "espeakNgData"))),
97
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dictDir"))),
98
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lmMain"))),
99
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lmFlow"))),
100
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "textConditioner"))),
101
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pocketEncoder"))),
102
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pocketDecoder"))),
103
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vocabJson"))),
104
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokenScoresJson"))),
105
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "zipvoiceEncoder"))),
106
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "zipvoiceDecoder"))),
107
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "config"))),
108
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "numThreads"))),
109
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputSampleRate"))),
110
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speakerId"))),
111
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))
112
+ );
113
+ }
114
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::onnx::speech::TtsModelConfig& arg) {
115
+ jsi::Object obj(runtime);
116
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<margelo::nitro::onnx::speech::TtsModelType>::toJSI(runtime, arg.type));
117
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "modelDir"), JSIConverter<std::string>::toJSI(runtime, arg.modelDir));
118
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "model"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.model));
119
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "acousticModel"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.acousticModel));
120
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "vocoder"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.vocoder));
121
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "tokens"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.tokens));
122
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "lexicon"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.lexicon));
123
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "voices"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.voices));
124
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "espeakNgData"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.espeakNgData));
125
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "dictDir"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.dictDir));
126
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "lmMain"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.lmMain));
127
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "lmFlow"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.lmFlow));
128
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "textConditioner"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.textConditioner));
129
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "pocketEncoder"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.pocketEncoder));
130
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "pocketDecoder"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.pocketDecoder));
131
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "vocabJson"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.vocabJson));
132
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "tokenScoresJson"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.tokenScoresJson));
133
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "zipvoiceEncoder"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.zipvoiceEncoder));
134
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "zipvoiceDecoder"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.zipvoiceDecoder));
135
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "config"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.config));
136
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "numThreads"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.numThreads));
137
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "outputSampleRate"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.outputSampleRate));
138
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "speakerId"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.speakerId));
139
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.speed));
140
+ return obj;
141
+ }
142
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
143
+ if (!value.isObject()) {
144
+ return false;
145
+ }
146
+ jsi::Object obj = value.getObject(runtime);
147
+ if (!nitro::isPlainObject(runtime, obj)) {
148
+ return false;
149
+ }
150
+ if (!JSIConverter<margelo::nitro::onnx::speech::TtsModelType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
151
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modelDir")))) return false;
152
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "model")))) return false;
153
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "acousticModel")))) return false;
154
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vocoder")))) return false;
155
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokens")))) return false;
156
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lexicon")))) return false;
157
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "voices")))) return false;
158
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "espeakNgData")))) return false;
159
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dictDir")))) return false;
160
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lmMain")))) return false;
161
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lmFlow")))) return false;
162
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "textConditioner")))) return false;
163
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pocketEncoder")))) return false;
164
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pocketDecoder")))) return false;
165
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vocabJson")))) return false;
166
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokenScoresJson")))) return false;
167
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "zipvoiceEncoder")))) return false;
168
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "zipvoiceDecoder")))) return false;
169
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "config")))) return false;
170
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "numThreads")))) return false;
171
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputSampleRate")))) return false;
172
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speakerId")))) return false;
173
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
174
+ return true;
175
+ }
176
+ };
177
+
178
+ } // namespace margelo::nitro
@@ -0,0 +1,88 @@
1
+ ///
2
+ /// TtsModelType.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::onnx::speech {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (TtsModelType).
30
+ */
31
+ enum class TtsModelType {
32
+ KOKORO SWIFT_NAME(kokoro) = 0,
33
+ VITS SWIFT_NAME(vits) = 1,
34
+ MATCHA SWIFT_NAME(matcha) = 2,
35
+ POCKET SWIFT_NAME(pocket) = 3,
36
+ ZIPVOICE SWIFT_NAME(zipvoice) = 4,
37
+ } CLOSED_ENUM;
38
+
39
+ } // namespace margelo::nitro::onnx::speech
40
+
41
+ namespace margelo::nitro {
42
+
43
+ // C++ TtsModelType <> JS TtsModelType (union)
44
+ template <>
45
+ struct JSIConverter<margelo::nitro::onnx::speech::TtsModelType> final {
46
+ static inline margelo::nitro::onnx::speech::TtsModelType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
47
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
48
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
49
+ case hashString("kokoro"): return margelo::nitro::onnx::speech::TtsModelType::KOKORO;
50
+ case hashString("vits"): return margelo::nitro::onnx::speech::TtsModelType::VITS;
51
+ case hashString("matcha"): return margelo::nitro::onnx::speech::TtsModelType::MATCHA;
52
+ case hashString("pocket"): return margelo::nitro::onnx::speech::TtsModelType::POCKET;
53
+ case hashString("zipvoice"): return margelo::nitro::onnx::speech::TtsModelType::ZIPVOICE;
54
+ default: [[unlikely]]
55
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum TtsModelType - invalid value!");
56
+ }
57
+ }
58
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::onnx::speech::TtsModelType arg) {
59
+ switch (arg) {
60
+ case margelo::nitro::onnx::speech::TtsModelType::KOKORO: return JSIConverter<std::string>::toJSI(runtime, "kokoro");
61
+ case margelo::nitro::onnx::speech::TtsModelType::VITS: return JSIConverter<std::string>::toJSI(runtime, "vits");
62
+ case margelo::nitro::onnx::speech::TtsModelType::MATCHA: return JSIConverter<std::string>::toJSI(runtime, "matcha");
63
+ case margelo::nitro::onnx::speech::TtsModelType::POCKET: return JSIConverter<std::string>::toJSI(runtime, "pocket");
64
+ case margelo::nitro::onnx::speech::TtsModelType::ZIPVOICE: return JSIConverter<std::string>::toJSI(runtime, "zipvoice");
65
+ default: [[unlikely]]
66
+ throw std::invalid_argument("Cannot convert TtsModelType to JS - invalid value: "
67
+ + std::to_string(static_cast<int>(arg)) + "!");
68
+ }
69
+ }
70
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
71
+ if (!value.isString()) {
72
+ return false;
73
+ }
74
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
75
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
76
+ case hashString("kokoro"):
77
+ case hashString("vits"):
78
+ case hashString("matcha"):
79
+ case hashString("pocket"):
80
+ case hashString("zipvoice"):
81
+ return true;
82
+ default:
83
+ return false;
84
+ }
85
+ }
86
+ };
87
+
88
+ } // namespace margelo::nitro
@@ -0,0 +1,91 @@
1
+ ///
2
+ /// TtsResult.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
+
32
+
33
+ #include <NitroModules/ArrayBuffer.hpp>
34
+
35
+ namespace margelo::nitro::onnx::speech {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (TtsResult).
39
+ */
40
+ struct TtsResult final {
41
+ public:
42
+ std::shared_ptr<ArrayBuffer> samples SWIFT_PRIVATE;
43
+ double sampleRate SWIFT_PRIVATE;
44
+ double durationMs SWIFT_PRIVATE;
45
+
46
+ public:
47
+ TtsResult() = default;
48
+ explicit TtsResult(std::shared_ptr<ArrayBuffer> samples, double sampleRate, double durationMs): samples(samples), sampleRate(sampleRate), durationMs(durationMs) {}
49
+
50
+ public:
51
+ friend bool operator==(const TtsResult& lhs, const TtsResult& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::onnx::speech
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ TtsResult <> JS TtsResult (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::onnx::speech::TtsResult> final {
61
+ static inline margelo::nitro::onnx::speech::TtsResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::onnx::speech::TtsResult(
64
+ JSIConverter<std::shared_ptr<ArrayBuffer>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "samples"))),
65
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sampleRate"))),
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs")))
67
+ );
68
+ }
69
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::onnx::speech::TtsResult& arg) {
70
+ jsi::Object obj(runtime);
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "samples"), JSIConverter<std::shared_ptr<ArrayBuffer>>::toJSI(runtime, arg.samples));
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "sampleRate"), JSIConverter<double>::toJSI(runtime, arg.sampleRate));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "durationMs"), JSIConverter<double>::toJSI(runtime, arg.durationMs));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<std::shared_ptr<ArrayBuffer>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "samples")))) return false;
85
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sampleRate")))) return false;
86
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs")))) return false;
87
+ return true;
88
+ }
89
+ };
90
+
91
+ } // namespace margelo::nitro