| 56 | } |
| 57 | |
| 58 | std::vector<float> durations_from_request(const runtime::TaskRequest & request, int batch_size) { |
| 59 | std::vector<float> durations; |
| 60 | if (const auto value = runtime::find_option(request.options, {"duration_seconds"})) { |
| 61 | durations = split_float_list(*value, "duration_seconds"); |
| 62 | } else { |
| 63 | durations.push_back(120.0F); |
| 64 | } |
| 65 | if (durations.size() == 1 && batch_size > 1) { |
| 66 | durations.resize(static_cast<size_t>(batch_size), durations.front()); |
| 67 | } |
| 68 | if (durations.size() != static_cast<size_t>(batch_size)) { |
| 69 | throw std::runtime_error("Stable Audio duration count must be one or match batch_size"); |
| 70 | } |
| 71 | for (const float duration : durations) { |
| 72 | require_positive(duration, "duration"); |
| 73 | } |
| 74 | return durations; |
| 75 | } |
| 76 | |
| 77 | std::vector<std::string> prompts_from_request(const runtime::TaskRequest & request, int batch_size) { |
| 78 | std::string prompt; |
no test coverage detected