Skip to content

Commit b68dd29

Browse files
committed
Apply review suggestions
1 parent 94582fb commit b68dd29

22 files changed

Lines changed: 50 additions & 66 deletions

File tree

docs/docs/04-typescript-api/01-natural-language-processing/TextToSpeechModule.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ const audioContext = new AudioContext({ sampleRate: 44100 });
105105

106106
try {
107107
const waveform = await tts.forward(
108-
'Hello from ExecuTorch!',
109-
1.0,
110-
true,
111-
8,
112-
'en'
108+
'Hello from ExecuTorch!', // Input text
109+
1.0, // Speed
110+
true, // Phonemize the input (Kokoro only)
111+
8, // Number of steps (Supertonic only)
112+
'en' // Language (Supertonic only)
113113
);
114114
// Kokoro: tts.forward('Hello from ExecuTorch!', 1.0)
115115

packages/react-native-executorch/common/rnexecutorch/host_objects/ModelHostObject.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,24 +219,8 @@ template <typename Model> class ModelHostObject : public JsiHostObject {
219219
JSI_EXPORT_FUNCTION(ModelHostObject<Model>, unload, "unload"));
220220
}
221221

222-
if constexpr (meta::SameAs<Model, models::text_to_speech::kokoro::Kokoro>) {
223-
addFunctions(
224-
JSI_EXPORT_FUNCTION(ModelHostObject<Model>, unload, "unload"));
225-
addFunctions(JSI_EXPORT_FUNCTION(ModelHostObject<Model>,
226-
promiseHostFunction<&Model::stream>,
227-
"stream"));
228-
addFunctions(JSI_EXPORT_FUNCTION(
229-
ModelHostObject<Model>, synchronousHostFunction<&Model::streamStop>,
230-
"streamStop"));
231-
addFunctions(JSI_EXPORT_FUNCTION(
232-
ModelHostObject<Model>, synchronousHostFunction<&Model::streamInsert>,
233-
"streamInsert"));
234-
addFunctions(JSI_EXPORT_FUNCTION(
235-
ModelHostObject<Model>, synchronousHostFunction<&Model::streamFlush>,
236-
"streamFlush"));
237-
}
238-
239-
if constexpr (meta::SameAs<
222+
if constexpr (meta::SameAs<Model, models::text_to_speech::kokoro::Kokoro> ||
223+
meta::SameAs<
240224
Model, models::text_to_speech::supertonic::Supertonic>) {
241225
addFunctions(
242226
JSI_EXPORT_FUNCTION(ModelHostObject<Model>, unload, "unload"));

packages/react-native-executorch/common/rnexecutorch/models/text_to_speech/common/Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ inline const std::unordered_set<char32_t> kPauseCharacters = {
2424
U'»', // Right Guillemet (U+00BB)
2525
};
2626

27-
} // namespace rnexecutorch::models::text_to_speech::constants
27+
} // namespace rnexecutorch::models::text_to_speech::constants

packages/react-native-executorch/common/rnexecutorch/models/text_to_speech/common/TextPartitioner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ TextPartitioner::Partition TextPartitioner::partition(std::u32string_view input,
102102
return {input, std::move(segments)};
103103
}
104104

105-
} // namespace rnexecutorch::models::text_to_speech
105+
} // namespace rnexecutorch::models::text_to_speech

packages/react-native-executorch/common/rnexecutorch/models/text_to_speech/common/TextPartitioner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class TextPartitioner {
7575
segments; // Pairs of {offset, length} for each segment.
7676
};
7777

78-
TextPartitioner(const TextPartitionerConfig &config);
78+
explicit TextPartitioner(const TextPartitionerConfig &config);
7979

8080
/**
8181
* Partitions the input text into segments.
@@ -91,4 +91,4 @@ class TextPartitioner {
9191
TextPartitionerConfig config_;
9292
};
9393

94-
} // namespace rnexecutorch::models::text_to_speech
94+
} // namespace rnexecutorch::models::text_to_speech

packages/react-native-executorch/common/rnexecutorch/models/text_to_speech/common/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ std::span<const float> stripAudio(std::span<const float> audio, size_t margin,
6666
return audio.subspan(lbound, strippedLength);
6767
}
6868

69-
} // namespace rnexecutorch::models::text_to_speech::utils
69+
} // namespace rnexecutorch::models::text_to_speech::utils

packages/react-native-executorch/common/rnexecutorch/models/text_to_speech/common/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ std::span<const float> stripAudio(std::span<const float> audio,
1818
uint32_t croppingSteps = 10,
1919
float silenceThreshold = 0.005F);
2020

21-
} // namespace rnexecutorch::models::text_to_speech::utils
21+
} // namespace rnexecutorch::models::text_to_speech::utils

packages/react-native-executorch/common/rnexecutorch/models/text_to_speech/kokoro/Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ inline const std::unordered_map<char32_t, Token> kVocab = {
6767
inline constexpr Token kInvalidToken = -1;
6868
inline constexpr Token kPadToken = 0;
6969

70-
} // namespace rnexecutorch::models::text_to_speech::kokoro::constants
70+
} // namespace rnexecutorch::models::text_to_speech::kokoro::constants

packages/react-native-executorch/common/rnexecutorch/models/text_to_speech/kokoro/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ std::vector<Token> tokenize(std::u32string_view phonemes,
4343
return tokens;
4444
}
4545

46-
} // namespace rnexecutorch::models::text_to_speech::kokoro::utils
46+
} // namespace rnexecutorch::models::text_to_speech::kokoro::utils

packages/react-native-executorch/common/rnexecutorch/models/text_to_speech/kokoro/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ namespace rnexecutorch::models::text_to_speech::kokoro::utils {
1616
std::vector<Token> tokenize(std::u32string_view phonemes,
1717
std::optional<size_t> expectedSize = std::nullopt);
1818

19-
} // namespace rnexecutorch::models::text_to_speech::kokoro::utils
19+
} // namespace rnexecutorch::models::text_to_speech::kokoro::utils

0 commit comments

Comments
 (0)