| 112 | } |
| 113 | |
| 114 | minitts::app::AppBatchRequest build_request_sequence_from_json( |
| 115 | const std::filesystem::path & sequence_path) { |
| 116 | const auto root = engine::io::json::parse_file(sequence_path); |
| 117 | const auto * requests_value = root.is_array() ? &root : root.find("requests"); |
| 118 | if (requests_value == nullptr) { |
| 119 | throw std::runtime_error("request sequence json requires an array or a requests array"); |
| 120 | } |
| 121 | minitts::app::AppBatchRequest batch; |
| 122 | const auto base_dir = sequence_path.parent_path(); |
| 123 | int index = 0; |
| 124 | for (const auto & item : requests_value->as_array()) { |
| 125 | std::ostringstream fallback; |
| 126 | fallback << "request_" << index; |
| 127 | batch.requests.push_back(minitts::app::AppRequest{ |
| 128 | json_optional_string(item, "id").value_or(fallback.str()), |
| 129 | build_request_from_json(item, base_dir), |
| 130 | }); |
| 131 | ++index; |
| 132 | } |
| 133 | if (batch.requests.empty()) { |
| 134 | throw std::runtime_error("request sequence must contain at least one request"); |
| 135 | } |
| 136 | return batch; |
| 137 | } |
| 138 | |
| 139 | minitts::app::AppBatchRequest build_text_file_batch( |
| 140 | const std::filesystem::path & path, |
no test coverage detected