Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing a loop to analyze hundreds of wav files in one folder #12

Open
lenawarbler opened this issue Oct 14, 2021 · 6 comments
Open

Writing a loop to analyze hundreds of wav files in one folder #12

lenawarbler opened this issue Oct 14, 2021 · 6 comments

Comments

@lenawarbler
Copy link

lenawarbler commented Oct 14, 2021

Hi BirdNET fans. I recently switched from BirdNET to BirdNET-Lite and noticed the input file requirements are slightly different.

With the original version, I could specify an input folder ('/mnt/c/folder') and BirdNET would set to work analyzing the hundreds of wav files within. However BirdNET-Lite seems to require a specific file name to work ('/mnt/c/folder/audiofile.wav').

What is appropriate syntax for analyzing 1000 wav files inside one folder? (I am using Ubuntu for Windows).

Here is pseudo-code for what I am trying to do:

for filename in /mnt/c/folder/*.wav; do
python3 analyze.py --i /mnt/c/folder/"$filename" --o /mnt/c/folder/"$filename".csv
done

Perhaps there is an easier way I am not seeing... I am new to Linux! I appreciate your help!

Update: It was easier than I thought! This code will analyze all wavs in a folder and save a csv with the same name

for filename in /mnt/c/folder/*.wav; do
python3 analyze.py --i $filename --o "$filename.csv"
done

@DD4WH
Copy link

DD4WH commented Oct 15, 2021

@lenawarbler
You might also want to check for this version which was modified specifically for batch processing:
https://github.com/FloMee/BirdNET-Lite

@JacobGlennAyers
Copy link

Hi there! Similar to the comment above, we encountered the same problem, so we implemented the ability to recursively go through folders given a path on our fork here: https://github.com/UCSD-E4E/BirdNET-Lite

@johannesnelson
Copy link

johannesnelson commented Feb 10, 2022

@JacobGlennAyers
Hi Jacob. Thanks for creating this. I successfully get this to run through audio files on folders on my mac, but when I run it on my PC with Windows 11, I get the following error: "Error in processing file: C:\Users\johan\BirdNET-Lite-batch-2\example\file2.wav"

It is probably an easy fix, but I have very limited experience with any of this. Any help getting this to run on my PC would be much appreciated!

@JacobGlennAyers
Copy link

JacobGlennAyers commented Feb 10, 2022 via email

@johannesnelson
Copy link

johannesnelson commented Feb 10, 2022

@JacobGlennAyers Thanks for getting back to me.

Edit: I resolved this by editing the analyze.py script so that all of the '/' characters in the relevant section were replaced with double backslash and it works now. Thanks again, this will save me a lot of time!

@JacobGlennAyers
Copy link

@m1sterjay Thanks for finding a bug, we made a quick fix to the repo using the builtin python os library (automagically handles '\' and '/') in order to make it more platform independent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants