MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / build_text_dir_batch

Function build_text_dir_batch

app/cli/batch.cpp:170–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170minitts::app::AppBatchRequest build_text_dir_batch(
171 const std::filesystem::path & dir,
172 const engine::runtime::TaskRequest & base_request,
173 const std::string & language) {
174 if (!std::filesystem::is_directory(dir)) {
175 throw std::runtime_error("--batch-text-dir must be an existing directory: " + dir.string());
176 }
177 std::vector<std::filesystem::path> text_paths;
178 for (const auto & entry : std::filesystem::directory_iterator(dir)) {
179 if (entry.is_regular_file() && text_batch_format_for(entry.path()) != nullptr) {
180 text_paths.push_back(entry.path());
181 }
182 }
183 std::sort(text_paths.begin(), text_paths.end());
184 if (text_paths.empty()) {
185 throw std::runtime_error(
186 "--batch-text-dir contains no supported text files (" + supported_text_batch_extensions() + "): " +
187 dir.string());
188 }
189
190 minitts::app::AppBatchRequest batch;
191 batch.requests.reserve(text_paths.size());
192 for (const auto & path : text_paths) {
193 const auto * format = text_batch_format_for(path);
194 const auto paragraph = format->read(path);
195 if (paragraph.empty()) {
196 throw std::runtime_error("--batch-text-dir file contains no non-whitespace text: " + path.string());
197 }
198 auto request = base_request;
199 request.text_input = engine::runtime::Transcript{paragraph, language};
200 batch.requests.push_back(minitts::app::AppRequest{path.stem().string(), std::move(request)});
201 }
202 return batch;
203}
204
205minitts::app::AppBatchRequest build_audio_dir_batch(
206 const std::filesystem::path & dir,

Callers 1

Calls 7

text_batch_format_forFunction · 0.85
readMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected