benfmiller / audalign

Package for aligning audio files through audio fingerprinting
MIT License
84 stars 2 forks source link

Request for a feature to control audio normalization before finding offset #45

Closed EGA-SUPREMO closed 1 year ago

EGA-SUPREMO commented 1 year ago

I need to make a script that finds the cuts in an audio, and for that I have decided to make cuts of one second for an audio. Apparently, Audalign already does that, but since I don't know how to modify it, I have not chosen that option.

After making cuts with my script, and then finding the offset with audalign, in some cases it give bad results, as each audio piece is normalized individually . So I would like to know if there is any way to prevent the audio from being normalized, and do the normalization myself.

benfmiller commented 1 year ago

Sounds like a fun project!

Audalign has a write_processed_file function that takes a start_end tuple that trims a file and writes it to a new location. start_end (tuple(float, float), optional): Silences before and after start and end. (0, -1) Silences last second, (5.4, 0) silences first 5.4 seconds. I don't know if that would be useful for your situation, though.

There isn't currently an option to disable normalizing during fingerprinting, but there is a way to write the unprocessed files with shifts applied to them after fingerprinting through the write_shifts_from_results function. Normalization happens here, filehandler.py#L76

The recognizers all require that the files have the same sample rate, width, and channels. Would you want a normalize=false setting in the BaseConfig that still applies the other processing but doesn't normalize?

EGA-SUPREMO commented 1 year ago

The recognizers all require that the files have the same sample rate, width, and channels. Would you want a normalize=false setting in the BaseConfig that still applies the other processing but doesn't normalize?

Yes, however as of now, if I remove this line: filehandler.py#L76, I would have disabled the normalization while applying the other processing? also I don't use write_shifts_from_results, so that wouldn't matter in this case

benfmiller commented 1 year ago

Sounds good!

Yes, the other processing would still apply with no normalization if you removed that line

EGA-SUPREMO commented 1 year ago

Thanks for the helpful answers. I really appreciate you taking the time to explain Audalign to me. And a big thanks to you for creating this program. It's been a huge help.

benfmiller commented 1 year ago

Thanks! I'm glad it's useful for you

I just released a new version v1.2.2 and merged to main a normalize field in the BaseConfig so you can choose to enable it or not

EGA-SUPREMO commented 1 year ago

Thanks!