| 137 | } |
| 138 | |
| 139 | minitts::app::AppBatchRequest build_text_file_batch( |
| 140 | const std::filesystem::path & path, |
| 141 | const engine::runtime::TaskRequest & base_request, |
| 142 | const std::string & language) { |
| 143 | std::ifstream input(path); |
| 144 | if (!input) { |
| 145 | throw std::runtime_error("failed to open --batch-text-file: " + path.string()); |
| 146 | } |
| 147 | minitts::app::AppBatchRequest batch; |
| 148 | std::string line; |
| 149 | int line_number = 0; |
| 150 | while (std::getline(input, line)) { |
| 151 | ++line_number; |
| 152 | if (!line.empty() && line.back() == '\r') { |
| 153 | line.pop_back(); |
| 154 | } |
| 155 | if (line.empty()) { |
| 156 | continue; |
| 157 | } |
| 158 | auto request = base_request; |
| 159 | request.text_input = engine::runtime::Transcript{line, language}; |
| 160 | std::ostringstream id; |
| 161 | id << "line_" << line_number; |
| 162 | batch.requests.push_back(minitts::app::AppRequest{id.str(), std::move(request)}); |
| 163 | } |
| 164 | if (batch.requests.empty()) { |
| 165 | throw std::runtime_error("--batch-text-file contains no non-empty requests"); |
| 166 | } |
| 167 | return batch; |
| 168 | } |
| 169 | |
| 170 | minitts::app::AppBatchRequest build_text_dir_batch( |
| 171 | const std::filesystem::path & dir, |
no test coverage detected