Skip to content
Snippets Groups Projects
Commit dd106a1d authored by Paul Best's avatar Paul Best
Browse files

no more filtering noisy bins or vocs

parent 5477ccb6
Branches
No related tags found
No related merge requests found
File deleted
File deleted
File deleted
from glob import glob
from p_tqdm import p_umap
from scipy import signal, interpolate
import pandas as pd, numpy as np
from metadata import species
import librosa, mir_eval
import os, shutil, argparse
parser = argparse.ArgumentParser()
parser.add_argument('specie', type=str, help="Species to treat specifically", default=None)
args = parser.parse_args()
for specie in species if args.specie is None else [args.specie]: wavpath, FS, nfft, downsample = species[specie].values()
os.system(f'rm -R \"noisy_pngs/{wavpath.split("*")[0]}/*\"')
dt = nfft / 8 / FS # winsize / 8
def fun(fn):
df = pd.read_csv(f'{fn[:-4]}_preds.csv')
if 'salience' in df.columns and (df.salience.quantile(.25) < 0.2 or df.SHR.quantile(.75) > 0):
# print(fn, snr, subharSNR)
if not os.path.isdir(f'noisy_pngs/{fn.rsplit("/",1)[0]}'):
os.mkdir(f'noisy_pngs/{fn.rsplit("/",1)[0]}')
shutil.copyfile(f'annot_pngs/{fn[:-4]}.png', f'noisy_pngs/{fn[:-4]}.png')
return 1
else:
return 0
count = p_umap(fun, glob(wavpath), desc=specie)
print(f'dropped {sum(count)} vocs out of {len(glob(wavpath))}')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment