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

Method run

src/models/voxcpm2/session.cpp:208–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206 decoder_config_.latent_frame_capacity);
207 decoder_config_.encoder_sample_capacity = runtime::parse_positive_i64_option(
208 options.options, {"voxcpm2.audiovae_encoder_sample_capacity"},
209 decoder_config_.encoder_sample_capacity);
210 parse_weight_type(options.options, "voxcpm2.weight_type",
211 generator_config_.weight_storage_type);
212 parse_weight_type(options.options, "voxcpm2.audiovae_weight_type",
213 decoder_config_.weight_storage_type);
214 if (const auto mem_saver =
215 runtime::find_option(options.options, {"voxcpm2.mem_saver"})) {
216 generator_config_.mem_saver =
217 runtime::parse_bool_option(*mem_saver, "voxcpm2.mem_saver");
218 }
219
220 generator_ = std::make_unique<VoxCPM2FeatureGeneratorRuntime>(
221 assets_, execution_context(), generator_config_);
222 decoder_ = std::make_unique<VoxCPM2AudioVAEDecoderRuntime>(
223 assets_, execution_context(), decoder_config_);
224}
225
226VoxCPM2SessionBase::~VoxCPM2SessionBase() = default;
227
228std::string VoxCPM2SessionBase::family_impl() const { return "voxcpm2"; }
229
230runtime::VoiceTaskKind VoxCPM2SessionBase::task_kind_impl() const { return task_.task; }
231
232runtime::RunMode VoxCPM2SessionBase::run_mode_impl() const { return task_.mode; }
233
234void VoxCPM2SessionBase::prepare_impl(
235 const runtime::SessionPreparationRequest &request) {
236 (void)request;
237 mark_prepared();
238}
239
240runtime::TaskResult VoxCPM2SessionBase::run_offline_request(const runtime::TaskRequest &request) {
241 require_prepared("VoxCPM2 run");
242 if (task_.mode != runtime::RunMode::Offline) {
243 throw std::runtime_error("VoxCPM2 run requires an offline session");
244 }
245 validate_request(request);
246 auto release_runtime_memory = [this](VoxCPM2SessionBase *self) {
247 if (self != nullptr) {
248 self->release_request_runtime_memory();
249 }
250 };
251 std::unique_ptr<VoxCPM2SessionBase, decltype(release_runtime_memory)>
252 release_guard(generator_config_.mem_saver ? this : nullptr,
253 release_runtime_memory);
254
255 const auto wall_start = Clock::now();
256 const int64_t text_chunk_size =
257 engine::text::parse_text_chunk_size_override(request.options).value_or(kDefaultTextChunkSize);
258 const auto text_chunk_mode =
259 engine::text::parse_text_chunk_mode_override(request.options)
260 .value_or(engine::text::TextChunkMode::TagAware);
261 const auto chunk_requests =
262 runtime::chunk_text_request(request, text_chunk_size, text_chunk_mode);
263 const auto generation_options = generation_options_from_request(request);
264 const auto prompt_text =
265 runtime::find_option(request.options, {"voxcpm2.prompt_text",

Callers

nothing calls this directly

Calls 13

chunk_text_requestFunction · 0.85
find_optionFunction · 0.85
append_audio_bufferFunction · 0.85
productFunction · 0.70
elapsed_msFunction · 0.50
timing_log_scalarFunction · 0.50
generateMethod · 0.45
decode_featuresMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected