BirdNET-Analyzer
BirdNET-Analyzer copied to clipboard
Add an option for not analyzing files that have been analyzed
When dealing with large amount of data (and thus long processing time) the server can unexpectedly crash, shutting down the analysis. It would be great if there was an option for avoiding the analysis of files that have already been analyzed.
I made a very quick fix but I am pretty much sure this can be optimized. In the function analyzeFile I added:
def analyzeFile(item):
# Get file path and restore cfg
fpath = item[0]
cfg.setConfig(item[1])
# CUSTOM - CHECK IF THE FILE ALREADY EXISTS
rpath = fpath.replace(cfg.INPUT_PATH, '')
rpath = rpath[1:] if rpath[0] in ['/', '\\'] else rpath
# Check if file already exists and if it does skip the analysis
if cfg.RESULT_TYPE == 'table':
rtype = '.BirdNET.selection.table.txt'
elif cfg.RESULT_TYPE == 'audacity':
rtype = '.BirdNET.results.txt'
else:
rtype = '.BirdNET.results.csv'
outname = os.path.join(cfg.OUTPUT_PATH, rpath.rsplit('.', 1)[0] + rtype)
if os.path.exists(outname):
print("File {} already exists".format(outname))
else:
DO THE REST OF THE ANALYSIS
Hi! Something like this is on our agenda and will also be added to the GUI. Thanks for sharing!