MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / HTDemucsSession

Method HTDemucsSession

src/models/demucs/session.cpp:133–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133HTDemucsSession::~HTDemucsSession() = default;
134
135std::string HTDemucsSession::family() const {
136 return kFamily;
137}
138
139runtime::VoiceTaskKind HTDemucsSession::task_kind() const {
140 return task_.task;
141}
142
143runtime::RunMode HTDemucsSession::run_mode() const {
144 return task_.mode;
145}
146
147void 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
168runtime::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

Callers

nothing calls this directly

Calls 7

option_weight_typeFunction · 0.70
sizeMethod · 0.45
uses_host_graph_planMethod · 0.45
backend_typeMethod · 0.45
resizeMethod · 0.45
release_storageMethod · 0.45

Tested by

no test coverage detected