| 332 | const std::string & label) { |
| 333 | if (!result.text_output.has_value()) { |
| 334 | throw std::runtime_error("--text-out was requested but the task result has no text output"); |
| 335 | } |
| 336 | if (!path.parent_path().empty()) { |
| 337 | std::filesystem::create_directories(path.parent_path()); |
| 338 | } |
| 339 | std::ofstream output(path); |
| 340 | if (!output) { |
| 341 | throw std::runtime_error("failed to open text output: " + path.string()); |
| 342 | } |
| 343 | output << result.text_output->text << "\n"; |
| 344 | std::cout << label << "=" << path.string() << "\n"; |
| 345 | } |
| 346 | |
| 347 | void print_task_help(const engine::runtime::ModelRegistry & registry, const std::string & task_name) { |
| 348 | const auto task = engine::runtime::parse_voice_task_kind(task_name); |
| 349 | std::cout |
| 350 | << "task=" << engine::runtime::to_string(task) << "\n" |
| 351 | << " Select a model to see model-owned options:\n" |
| 352 | << " audiocpp_cli --task " << engine::runtime::to_string(task) |
| 353 | << " --family <family> --model <path> --backend <backend> --help\n" |
| 354 | << " Registered families:\n"; |
| 355 | for (const auto & family : registry.families()) { |
| 356 | std::cout << " " << family << "\n"; |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | void print_inspection(const engine::runtime::ModelInspection & inspection) { |
| 361 | std::cout << "family=" << inspection.metadata.family << "\n"; |
| 362 | std::cout << "variant=" << inspection.metadata.variant << "\n"; |
| 363 | std::cout << "model_root=" << inspection.model_root.string() << "\n"; |
| 364 | std::cout << "supported_tasks=" << inspection.capabilities.supported_tasks.size() << "\n"; |
| 365 | for (const auto & capability : inspection.capabilities.supported_tasks) { |
| 366 | std::cout << "task=" << engine::runtime::to_string(capability.task) << " modes="; |
| 367 | for (size_t i = 0; i < capability.modes.size(); ++i) { |
| 368 | if (i != 0) { |
| 369 | std::cout << ","; |
| 370 | } |
| 371 | std::cout << engine::runtime::to_string(capability.modes[i]); |