Rikorose / DeepFilterNet

Noise supression using deep filtering
https://huggingface.co/spaces/hshr/DeepFilterNet2
Other
2.15k stars 198 forks source link

How to reuse the model instance, in Python? #525

Closed Mikkolehtimaki closed 1 week ago

Mikkolehtimaki commented 3 months ago

So calling init_df gives me the model and a state. If I want to make multiple calls to enhance, can I keep using the same state? Calling state.reset() does not seem to result in the same state as returned from init_df.

mattpitkin commented 3 months ago

[Caveat: this is what I think is happening, but I could be wrong.] When you create a new DFState, as returned from init_df, then memory for the frame analysis/synthesis (e.g., storing the part of the previous frame from the overlap) is zeroed and also the normalisation states for the spectrum and ERB spectrum will be initialised to specific values (the normalisations states are updated for each frame). When you call state.reset(), it resets the memory for the frame analysis/synthesis to zero, but it does not re-initialise the normalisations, which is why you see different results. If you are using a pre-used, but reset, state on independent audio, the fact that the normalisation was not reset can result is a short impulsive transient before the normalisation settles down and loses memory of the previous data that was passed through the state. (Note - you get a similar normalisation transient effect from a new state anyway as the normalisation starts at somewhat arbitrary values and takes a short time to see enough data to settle).

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.