Nachtzuster / BirdNET-Pi

A realtime acoustic bird classification system for the Raspberry Pi 5, 4B 3B+ 0W2 and more. Built on the TFLite version of BirdNET.
https://birdnetpi.com
Other
133 stars 20 forks source link

extract changed to prettify output file #124

Open morrowwm opened 3 months ago

morrowwm commented 3 months ago

Use python to trim, instead of sox. While the data is in python, reduce noise, filter and normalize, then output sound file.

You might want to reject this, and ask me to add configuration to make this optional, make the highpass cutoff configurable, output both enhanced and raw output files, or other complications. I think at least an enable/disable setting would be desirable. I will need a hint about how to do that nicely.

alexbelgium commented 3 months ago

Hi, there is already an "accessibility" part in config ; so it could also be looked as part of this ! For example we could have a toggle "clean audio sounds" that if enabled would use this code, if disabled (default) would give the raw sound. A bit like the "shift" feature

EDIT : I can help you with the "adding to settings part", I've done it a couple times and thing I now know where are all the things to take into account (or else you can look at a previous commit including a new config such as the "whitelist" PR already opened) ; you would just need to adapt the python to allow both based on a variable status (true/false)

morrowwm commented 3 months ago

OK, I will take a look over the next few days. I have some real life interruptions over the next ~100 hours.

I was looking at how this could also be used to "clean" the wav data sent to soundscape. That file is the entire 15 second sound data, which may include multiple detections. Correct?

If so, I should move the noise reduce+filter+normalize processing out to a general purpose function that takes an input file and returns an output file. Any opinion?

alexbelgium commented 3 months ago

Hi, files cleaning is controversial - some like it some hate it ;-) but indeed I've tried also (=spent hours on) trying to improve detection quality by using the noise-cancel module of pulseaudio, then instead bought a better microphone ;-) I think we should do some trial/errors if we wanted to implement that before anlaysis. I guess the best way would be to apply the filter when the soundscape from pulseaudio or rtsp is cut in the smaller 15-30s wav files for analysis...

Nachtzuster commented 3 months ago

It is interesting to have a replacement for sox, but the filtering does not really fit the BirdNET idea of keeping the recorded audio. Well I think so at least.

morrowwm commented 3 months ago

It is interesting to have a replacement for sox, but the filtering does not really fit the BirdNET idea of keeping the recorded audio. Well I think so at least.

I agree. If this idea does get incorporated, it needs to be an option. Many people have a good recording hardware setup, and have no need to do anything to the sound files.