| 131 | } |
| 132 | |
| 133 | HTDemucsSession::~HTDemucsSession() = default; |
| 134 | |
| 135 | std::string HTDemucsSession::family() const { |
| 136 | return kFamily; |
| 137 | } |
| 138 | |
| 139 | runtime::VoiceTaskKind HTDemucsSession::task_kind() const { |
| 140 | return task_.task; |
| 141 | } |
| 142 | |
| 143 | runtime::RunMode HTDemucsSession::run_mode() const { |
| 144 | return task_.mode; |
| 145 | } |
| 146 | |
| 147 | void HTDemucsSession::prepare(const runtime::SessionPreparationRequest & request) { |
| 148 | if (!request.audio.has_value()) { |
| 149 | throw std::runtime_error("HTDemucs prepare() requires an audio contract"); |
| 150 | } |
| 151 | const auto & config = pipeline_->config(); |
| 152 | if (request.audio->sample_rate != config.sample_rate) { |
| 153 | throw std::runtime_error( |
| 154 | "HTDemucs prepare() sample rate mismatch: expected " + |
| 155 | std::to_string(config.sample_rate) + ", got " + |
| 156 | std::to_string(request.audio->sample_rate)); |
| 157 | } |
| 158 | const bool mono_compatible = config.audio_channels == 2 && request.audio->channels == 1; |
| 159 | if (request.audio->channels != config.audio_channels && !mono_compatible) { |
| 160 | throw std::runtime_error( |
| 161 | "HTDemucs prepare() channel mismatch: expected " + |
| 162 | std::to_string(config.audio_channels) + ", got " + |
| 163 | std::to_string(request.audio->channels)); |
| 164 | } |
| 165 | mark_prepared(); |
| 166 | } |
| 167 | |
| 168 | runtime::TaskResult HTDemucsSession::run(const runtime::TaskRequest & request) { |
| 169 | require_prepared("HTDemucs run()"); |
| 170 | runtime::validate_spec_backed_request_options(request.options, *contract_, "HTDemucs"); |
| 171 | if (!request.audio_input.has_value()) { |
| 172 | throw std::runtime_error("HTDemucs run() requires audio_input"); |
| 173 | } |
| 174 |
nothing calls this directly
no test coverage detected