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

Function apply_init_audio

src/models/stable_audio/session.cpp:137–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void apply_init_audio(
138 StableAudioSamplingState & sampling,
139 const std::vector<float> & init_latents,
140 float init_noise_level,
141 const StableAudioConfig & config) {
142 if (static_cast<int64_t>(init_latents.size()) != config.latent_dim * sampling.latent_sample_size) {
143 throw std::runtime_error("Stable Audio init latent shape mismatch");
144 }
145 for (int64_t b = 0; b < sampling.batch; ++b) {
146 for (int64_t c = 0; c < config.latent_dim; ++c) {
147 for (int64_t t = 0; t < sampling.latent_sample_size; ++t) {
148 const size_t dst = static_cast<size_t>((b * config.latent_dim + c) * sampling.latent_sample_size + t);
149 const float init = init_latents[static_cast<size_t>(c * sampling.latent_sample_size + t)];
150 sampling.noise[dst] = init * (1.0F - init_noise_level) + sampling.noise[dst] * init_noise_level;
151 }
152 }
153 }
154}
155
156void apply_inpaint_conditioning(
157 StableAudioSamplingState & sampling,

Callers 1

runMethod · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected