| 1229 | } |
| 1230 | |
| 1231 | DeepFilterNet2Output 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 | |
| 1256 | DeepFilterNet2WaveformOutput DeepFilterNet2Model::run_mono_48k(const std::vector<float> & waveform) const { |
| 1257 | if (state_ == nullptr) { |
nothing calls this directly
no test coverage detected