BirdNET-Lite
BirdNET-Lite copied to clipboard
Writing a loop to analyze hundreds of wav files in one folder
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
@lenawarbler You might also want to check for this version which was modified specifically for batch processing: https://github.com/FloMee/BirdNET-Lite
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
@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!
Hi there, in Windows, the directories (folders) have paths like this with
characters, while linux, and MacOS use / characters. So, if you are working
with windows, change "example/important/path" to "example\important\path"
On Thu, Feb 10, 2022, 1:29 PM m1sterjay @.***> wrote:
@JacobGlennAyers https://github.com/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 running Windows 11, I get a file read 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!
— Reply to this email directly, view it on GitHub https://github.com/kahst/BirdNET-Lite/issues/12#issuecomment-1035538007, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6J6GBOM57HKKSARJVQ6ETU2QU25ANCNFSM5F6L7WJA . You are receiving this because you were mentioned.Message ID: @.***>
@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!
@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.