diff --git a/model/labels_l18n.zip b/model/labels_l18n.zip index 68a822b..9503754 100644 Binary files a/model/labels_l18n.zip and b/model/labels_l18n.zip differ diff --git a/scripts/daily_plot.py b/scripts/daily_plot.py index 90b517c..7632aed 100755 --- a/scripts/daily_plot.py +++ b/scripts/daily_plot.py @@ -1,9 +1,8 @@ #!/home/pi/BirdNET-Pi/birdnet/bin/python3 -import mysql.connector as sql +import sqlite3 import os import configparser - import pandas as pd import seaborn as sns import matplotlib.pyplot as plt @@ -11,25 +10,14 @@ from matplotlib.colors import LogNorm from datetime import datetime import textwrap -#Extract DB_PWD from thisrun.txt -with open('/home/pi/BirdNET-Pi/thisrun.txt', 'r') as f: - this_run = f.readlines() - db_pwd = str(str(str([i for i in this_run if i.startswith('DB_PWD')]).split('=')[1]).split('\\')[0]) +conn = sqlite3.connect('/home/pi/BirdNET-Pi/scripts/birds.db') +df = pd.read_sql_query("SELECT * from detections", conn) +cursor = conn.cursor() +cursor.execute('SELECT * FROM detections') +table_rows = cursor.fetchall() -db_connection = sql.connect(host='localhost', - database='birds', - user='birder', - password=db_pwd) - - -db_cursor=db_connection.cursor(dictionary=True) - -db_cursor.execute('SELECT * FROM detections') - -table_rows = db_cursor.fetchall() - -df=pd.DataFrame(table_rows) +#df=pd.DataFrame(table_rows) #Convert Date and Time Fields to Panda's format df['Date']=pd.to_datetime(df['Date']) diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh index 029edc6..651b723 100755 --- a/scripts/extract_new_birdsounds.sh +++ b/scripts/extract_new_birdsounds.sh @@ -61,14 +61,13 @@ for h in "${SCAN_DIRS[@]}";do SCIENTIFIC_NAME=""$(echo ${line} \ | awk -F\; '!/birdnet/{print $3}')"" CONFIDENCE=""$(echo ${line} \ - | awk -F\; '{print $5}' \ - | cut -d'.' -f2)"" - CONFIDENCE_SCORE="${CONFIDENCE:0:2}%" + | awk -F\; '{print $5}')"" + + #CONFIDENCE_SCORE="${CONFIDENCE:0:2}%" + CONFIDENCE_SCORE="$(printf %.0f $(echo "scale=2; ${CONFIDENCE} * 100" | bc))" NEWFILE="${COMMON_NAME// /_}-${CONFIDENCE_SCORE}-${OLDFILE//.wav/.${AUDIOFMT}}" echo "NEWFILE=$NEWFILE" NEWSPECIES_BYDATE="${EXTRACTED}/By_Date/${DATE}/${COMMON_NAME// /_}" - NEWSPECIES_BY_COMMON="${EXTRACTED}/By_Common_Name/${COMMON_NAME// /_}" - NEWSPECIES_BY_SCIENCE="${EXTRACTED}/By_Scientific_Name/${SCIENTIFIC_NAME// /_}" # If the extracted file already exists, move on if [[ -f "${NEWSPECIES_BYDATE}/${NEWFILE}" ]];then @@ -85,16 +84,6 @@ for h in "${SCAN_DIRS[@]}";do # it is created [[ -d "${NEWSPECIES_BYDATE}" ]] || mkdir -p "${NEWSPECIES_BYDATE}" - - # If a directory does not already exist for the species (by-species), - # it is created. - [[ -d "${NEWSPECIES_BY_COMMON}" ]] || mkdir -p "${NEWSPECIES_BY_COMMON}" - - # If a directory does not already exist for the species (by-species), - # it is created. - [[ -d "${NEWSPECIES_BY_SCIENCE}" ]] || mkdir -p "${NEWSPECIES_BY_SCIENCE}" - - # If there are already 20 extracted entries for a given species # for today, remove the oldest file and create the new one. # if [[ "$(find ${NEWSPECIES_BYDATE} | wc -l)" -ge 20 ]];then @@ -131,9 +120,6 @@ for h in "${SCAN_DIRS[@]}";do sox "${h}/${OLDFILE}" "${NEWSPECIES_BYDATE}/${NEWFILE}" \ trim "${START}" "${END}" - #ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \ - # -acodec copy -ss "${START}" -to "${END}"\ - # "${NEWSPECIES_BYDATE}/${NEWFILE}" # Create spectrogram for extraction sox "${NEWSPECIES_BYDATE}/${NEWFILE}" -n remix 1 rate 24k spectrogram \ @@ -141,48 +127,6 @@ for h in "${SCAN_DIRS[@]}";do -c "${NEWSPECIES_BYDATE}/${NEWFILE}" \ -o "${NEWSPECIES_BYDATE}/${NEWFILE}.png" - # Remove the oldest symbolic links that would make the directory have more - # than 20 entries. - if [[ "$(find ${NEWSPECIES_BY_COMMON} | wc -l)" -ge 40 ]];then - echo "20 ${SPECIES}s, already! Removing the oldest by-species and making a new one" - cd ${NEWSPECIES_BY_COMMON} || exit 1 - ls -1t . | tail -n +40 | xargs -r rm -vv - ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}"\ - "${NEWSPECIES_BY_COMMON}/${NEWFILE}" - ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}.png"\ - "${NEWSPECIES_BY_COMMON}/${NEWFILE}.png" - echo "Success! New extraction for ${COMMON_NAME}" - else - # Make symbolic link of the extraction to add to By_Common_Name - ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}"\ - "${NEWSPECIES_BY_COMMON}/${NEWFILE}" - ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}.png"\ - "${NEWSPECIES_BY_COMMON}/${NEWFILE}.png" - fi - - # Remove the oldest symbolic links that would made the directory have more - # than 20 entries. - if [[ "$(find ${NEWSPECIES_BY_SCIENCE} | wc -l)" -ge 40 ]];then - echo "20 ${SPECIES}s, already! Removing the oldest by-species and making a new one" - cd ${NEWSPECIES_BY_SCIENCE} || exit 1 - ls -1t . | tail -n +40 | xargs -r rm -vv - ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}"\ - "${NEWSPECIES_BY_SCIENCE}/${NEWFILE}" - ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}.png"\ - "${NEWSPECIES_BY_SCIENCE}/${NEWFILE}.png" - echo "Success! New extraction for ${COMMON_NAME}" - else - ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}"\ - "${NEWSPECIES_BY_SCIENCE}/${NEWFILE}" - ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}.png"\ - "${NEWSPECIES_BY_SCIENCE}/${NEWFILE}.png" - fi - - - # Finally, 'a' is incremented by one to allow multiple extractions per - # species per minute. - #a=$((a + 1)) - done < "${TMPFILE}" # Once each line of the TMPFILE has been processed, the TMPFILE is emptied @@ -192,11 +136,11 @@ for h in "${SCAN_DIRS[@]}";do # Rename files that have been processed so that they are not processed on the # next extraction. [[ -d "${PROCESSED}" ]] || mkdir "${PROCESSED}" - echo "Moving processed files to ${PROCESSED}" + #echo "Moving processed files to ${PROCESSED}" mv ${h}/* ${PROCESSED} &> /dev/null || continue done -echo "Linking Processed files to "${EXTRACTED}/Processed" web directory" +#echo "Linking Processed files to "${EXTRACTED}/Processed" web directory" # After all audio extractions have taken place, a directory is created to house # the original WAVE and .txt files used for this extraction processs. if [[ ! -L ${EXTRACTED}/Processed ]] || [[ ! -e ${EXTRACTED}/Processed ]];then diff --git a/scripts/history.php b/scripts/history.php index 9da8ee7..c8e0237 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -10,6 +10,14 @@ $theDate = date('Y-m-d'); } $chart = "Combo-$theDate.png"; $chart2 = "Combo2-$theDate.png"; + +$db = new SQLite3('/home/pi/BirdNET-Pi/scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE); + +$statement1 = $db->prepare("SELECT COUNT(*) FROM detections + WHERE Date == \"$theDate\""); +$result1 = $statement1->execute(); +$totalcount = $result1->fetchArray(SQLITE3_ASSOC); + ?>
@@ -52,7 +60,7 @@ hr {| Total Detections For The Day | -+ |
|---|
| Most Recent Detection | -"> | -+ | "> | +" target="footer"/> | More Info | |
|---|---|---|---|---|---|---|
| Number of Detections | - | + |
| Species Detected Today | -+ |
|---|
| Total | -Today | -Last Hour | -Number of Unique Species | -
|---|---|---|---|
| - | - | - | - |