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

Method run_features

src/framework/audio/deepfilternet2.cpp:1231–1254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1229}
1230
1231DeepFilterNet2Output DeepFilterNet2Model::run_features(
1232 const std::vector<float> & feat_erb,
1233 const std::vector<int64_t> & feat_erb_shape,
1234 const std::vector<float> & feat_spec,
1235 const std::vector<int64_t> & feat_spec_shape) const {
1236 if (state_ == nullptr) {
1237 throw std::runtime_error("DeepFilterNet2 model is not initialized");
1238 }
1239 auto erb = tensor4_from_values(feat_erb, feat_erb_shape, "feat_erb");
1240 auto spec = tensor4_from_values(feat_spec, feat_spec_shape, "feat_spec");
1241 if (erb.c != 1 || erb.f != 32 || spec.c != 2 || spec.f != 96 || erb.t != spec.t) {
1242 throw std::runtime_error("DeepFilterNet2 feature input shape mismatch");
1243 }
1244 if (!state_->forward_graph || !state_->forward_graph->matches(erb.t)) {
1245 state_->forward_graph.reset();
1246 state_->forward_graph = std::make_unique<DeepFilterNet2ForwardGraph>(
1247 state_->weights,
1248 state_->backend.get(),
1249 state_->backend_type,
1250 erb.t);
1251 }
1252 const auto output = state_->forward_graph->run(erb, spec);
1253 return DeepFilterNet2Output{output.erb_mask, output.df_coefs, output.enc_lsnr, output.df_alpha};
1254}
1255
1256DeepFilterNet2WaveformOutput DeepFilterNet2Model::run_mono_48k(const std::vector<float> & waveform) const {
1257 if (state_ == nullptr) {

Callers

nothing calls this directly

Calls 5

tensor4_from_valuesFunction · 0.85
matchesMethod · 0.45
resetMethod · 0.45
getMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected