";
} else {
echo "
No Detections For Today
";
diff --git a/scripts/play.php b/scripts/play.php
index a007341..8efb947 100644
--- a/scripts/play.php
+++ b/scripts/play.php
@@ -3,7 +3,7 @@ ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
-$db = new SQLite3('/home/pi/BirdNET-Pi/scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
+$db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
if($db == False){
echo "Database is busy";
header("refresh: 0;");
diff --git a/scripts/plotly_streamlit.py b/scripts/plotly_streamlit.py
index 507d872..b42906d 100755
--- a/scripts/plotly_streamlit.py
+++ b/scripts/plotly_streamlit.py
@@ -1,4 +1,4 @@
-#!/home/pi/BirdNET-Pi/birdnet/bin/python3
+import os
import streamlit as st
import pandas as pd
import numpy as np
@@ -9,7 +9,8 @@ from pathlib import Path
import sqlite3
from sqlite3 import Connection
-URI_SQLITE_DB = "/home/pi/BirdNET-Pi/scripts/birds.db"
+userDir = os.path.expanduser('~')
+URI_SQLITE_DB = userDir + '/BirdNET-Pi/scripts/birds.db'
st.set_page_config(layout='wide')
@@ -31,24 +32,12 @@ st.markdown("""
""", unsafe_allow_html=True)
-col1,col2,col3 = st.columns([20,20,20])
-
-col1.title('BirdNET-Pi', anchor=None)
-col2.image('/home/pi/BirdNET-Pi/homepage/images/bird.png')
-col3.text('')
-
@st.cache(hash_funcs={Connection: id})
def get_connection(path:str):
return sqlite3.connect(path,check_same_thread=False)
-
-
-# def load_data():
-# df1 = pd.read_csv('/home/pi/BirdNET-Pi/BirdDB.txt', sep=';')
-# return df1
-
def get_data(conn: Connection):
df1=pd.read_sql("SELECT * FROM detections", con=conn)
return df1
@@ -179,6 +168,6 @@ st.plotly_chart(fig, use_container_width=True) #, config=config)
#
# extract_date=Date_Slider
#
-# audio_file = open('/home/pi/BirdSongs/Extracted/By_Date/2022-03-22/Yellow-streaked_Greenbul/Yellow-streaked_Greenbul-77-2022-03-22-birdnet-15:04:28.mp3', 'rb')
+# audio_file = open('/home/*/BirdSongs/Extracted/By_Date/2022-03-22/Yellow-streaked_Greenbul/Yellow-streaked_Greenbul-77-2022-03-22-birdnet-15:04:28.mp3', 'rb')
# audio_bytes = audio_file.read()
-# cols4.audio(audio_bytes, format='audio/mp3')
\ No newline at end of file
+# cols4.audio(audio_bytes, format='audio/mp3')
diff --git a/scripts/privacy_server.py b/scripts/privacy_server.py
index 85efa21..15a5672 100755
--- a/scripts/privacy_server.py
+++ b/scripts/privacy_server.py
@@ -1,4 +1,3 @@
-#!/home/pi/BirdNET-Pi/birdnet/bin/python3
import socket
import threading
import os
@@ -44,7 +43,8 @@ except:
# Open most recent Configuration and grab DB_PWD as a python variable
-with open('/home/pi/BirdNET-Pi/thisrun.txt', 'r') as f:
+userDir = os.path.expanduser('~')
+with open(userDir + '/BirdNET-Pi/thisrun.txt', 'r') as f:
this_run = f.readlines()
audiofmt = "." + str(str(str([i for i in this_run if i.startswith('AUDIOFMT')]).split('=')[1]).split('\\')[0])
@@ -59,7 +59,8 @@ def loadModel():
print('LOADING TF LITE MODEL...', end=' ')
# Load TFLite model and allocate tensors.
- myinterpreter = tflite.Interpreter(model_path='/home/pi/BirdNET-Pi/model/BirdNET_6K_GLOBAL_MODEL.tflite',num_threads=2)
+ modelpath = userDir + '/BirdNET-Pi/model/BirdNET_6K_GLOBAL_MODEL.tflite'
+ myinterpreter = tflite.Interpreter(model_path=modelpath,num_threads=2)
myinterpreter.allocate_tensors()
# Get input and output tensors.
@@ -73,7 +74,7 @@ def loadModel():
# Load labels
CLASSES = []
- with open('/home/pi/BirdNET-Pi/model/labels.txt', 'r') as lfile:
+ with open(userDir + '/BirdNET-Pi/model/labels.txt', 'r') as lfile:
for line in lfile.readlines():
CLASSES.append(line.replace('\n', ''))
@@ -170,11 +171,11 @@ def predict(sample, sensitivity):
if p_sorted[i][0]=='Human_Human':
print("HUMAN SCORE:",str(p_sorted[i]))
HUMAN_FLAG=True
- with open('/home/pi/BirdNET-Pi/HUMAN.txt', 'a') as rfile:
+ with open(userDir + '/BirdNET-Pi/HUMAN.txt', 'a') as rfile:
rfile.write(str(datetime.datetime.now())+str(p_sorted[i])+ '\n')
# date_stamp=datetime.datetime.now().strftime("%d_%m_%y_%H:%M:%S")
#
-# sf.write('./home/pi/human_sample.wav',np.random.randn(10,2) , 44100) #sample[0]
+# sf.write('./home/*/human_sample.wav',np.random.randn(10,2) , 44100) #sample[0]
# Only return first the top ten results
#INCREASE THIS TO SEE IF HUMAN IS DETECTED MORE RELIABLY
@@ -259,8 +260,8 @@ def handle_client(conn, addr):
args = type('', (), {})()
- args.i = '/home/pi/test.wav'
- args.o = '/home/pi/test.wav.csv'
+ args.i = ''
+ args.o = ''
args.birdweather_id = '99999'
args.include_list = 'null'
args.exclude_list = 'null'
@@ -355,7 +356,7 @@ def handle_client(conn, addr):
myReturn += str(i) + '-' + str(detections[i][0]) + '\n'
- with open('/home/pi/BirdNET-Pi/BirdDB.txt', 'a') as rfile:
+ with open(userDir + '/BirdNET-Pi/BirdDB.txt', 'a') as rfile:
for d in detections:
for entry in detections[d]:
if entry[1] >= min_conf and ((entry[0] in INCLUDE_LIST or len(INCLUDE_LIST) == 0) and (entry[0] not in EXCLUDE_LIST or len(EXCLUDE_LIST) == 0) ):
@@ -381,7 +382,7 @@ def handle_client(conn, addr):
#Connect to SQLite Database
try:
- con = sqlite3.connect('/home/pi/BirdNET-Pi/scripts/birds.db')
+ con = sqlite3.connect(userDir + '/BirdNET-Pi/scripts/birds.db')
cur = con.cursor()
cur.execute("INSERT INTO detections VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (Date, Time, Sci_Name, Com_Name, str(score), Lat, Lon, Cutoff, Week, Sens, Overlap, File_Name))
diff --git a/scripts/restart_services.sh b/scripts/restart_services.sh
index cb5384b..2de8f0d 100755
--- a/scripts/restart_services.sh
+++ b/scripts/restart_services.sh
@@ -2,7 +2,7 @@
# Restarts ALL services and removes ALL unprocessed audio
source /etc/birdnet/birdnet.conf
set -x
-my_dir=/home/pi/BirdNET-Pi/scripts
+my_dir=$HOME/BirdNET-Pi/scripts
sudo systemctl stop birdnet_server.service
sudo pkill server.py
diff --git a/scripts/server.py b/scripts/server.py
index 6d0b129..0746b88 100755
--- a/scripts/server.py
+++ b/scripts/server.py
@@ -1,4 +1,3 @@
-#!/home/pi/BirdNET-Pi/birdnet/bin/python3
import socket
import threading
import os
@@ -44,7 +43,8 @@ except:
# Open most recent Configuration and grab DB_PWD as a python variable
-with open('/home/pi/BirdNET-Pi/thisrun.txt', 'r') as f:
+userDir = os.path.expanduser('~')
+with open(userDir + '/BirdNET-Pi/scripts/thisrun.txt', 'r') as f:
this_run = f.readlines()
audiofmt = "." + str(str(str([i for i in this_run if i.startswith('AUDIOFMT')]).split('=')[1]).split('\\')[0])
@@ -59,7 +59,8 @@ def loadModel():
print('LOADING TF LITE MODEL...', end=' ')
# Load TFLite model and allocate tensors.
- myinterpreter = tflite.Interpreter(model_path='/home/pi/BirdNET-Pi/model/BirdNET_6K_GLOBAL_MODEL.tflite',num_threads=2)
+ modelpath = userDir + '/BirdNET-Pi/model/BirdNET_6K_GLOBAL_MODEL.tflite'
+ myinterpreter = tflite.Interpreter(model_path=modelpath,num_threads=1)
myinterpreter.allocate_tensors()
# Get input and output tensors.
@@ -73,7 +74,8 @@ def loadModel():
# Load labels
CLASSES = []
- with open('/home/pi/BirdNET-Pi/model/labels.txt', 'r') as lfile:
+ labelspath = userDir + '/BirdNET-Pi/model/labels.txt'
+ with open(labelspath, 'r') as lfile:
for line in lfile.readlines():
CLASSES.append(line.replace('\n', ''))
@@ -233,8 +235,8 @@ def handle_client(conn, addr):
args = type('', (), {})()
- args.i = '/home/pi/test.wav'
- args.o = '/home/pi/test.wav.csv'
+ args.i = ''
+ args.o = ''
args.birdweather_id = '99999'
args.include_list = 'null'
args.exclude_list = 'null'
@@ -329,7 +331,7 @@ def handle_client(conn, addr):
myReturn += str(i) + '-' + str(detections[i][0]) + '\n'
- with open('/home/pi/BirdNET-Pi/BirdDB.txt', 'a') as rfile:
+ with open(userDir + '/BirdNET-Pi/BirdDB.txt', 'a') as rfile:
for d in detections:
for entry in detections[d]:
if entry[1] >= min_conf and ((entry[0] in INCLUDE_LIST or len(INCLUDE_LIST) == 0) and (entry[0] not in EXCLUDE_LIST or len(EXCLUDE_LIST) == 0) ):
@@ -354,16 +356,17 @@ def handle_client(conn, addr):
Date.replace("/", "-") + '-birdnet-' + Time + audiofmt
#Connect to SQLite Database
- try:
- con = sqlite3.connect('/home/pi/BirdNET-Pi/scripts/birds.db')
- cur = con.cursor()
- cur.execute("INSERT INTO detections VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (Date, Time, Sci_Name, Com_Name, str(score), Lat, Lon, Cutoff, Week, Sens, Overlap, File_Name))
+ #try:
+ con = sqlite3.connect(userDir + '/BirdNET-Pi/scripts/birds.db')
+ cur = con.cursor()
+ cur.execute("INSERT INTO detections VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (Date, Time, Sci_Name, Com_Name, str(score), Lat, Lon, Cutoff, Week, Sens, Overlap, File_Name))
+
+ con.commit()
+ con.close()
+ #except:
+ # print("Database busy")
+ # time.sleep(2)
- con.commit()
- con.close()
- except:
- print("Database busy")
- time.sleep(2)
print(str(current_date) + ';' + str(current_time) + ';' + entry[0].replace('_', ';') + ';' + str(entry[1]) + ';' + str(args.lat) + ';' + str(args.lon) + ';' + str(min_conf) + ';' + str(week) + ';' + str(args.sensitivity) +';' + str(args.overlap) + Com_Name.replace(" ", "_") + '-' + str(score) + '-' + str(current_date) + '-birdnet-' + str(current_time) + audiofmt + '\n')
if birdweather_id != "99999":
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index a7a01bc..9596754 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -10,7 +10,7 @@ lastcheck="$(mktemp)"
cp ${IDFILE} ${lastcheck}
-/home/pi/BirdNET-Pi/scripts/update_species.sh
+$HOME/BirdNET-Pi/scripts/update_species.sh
if ! diff ${IDFILE} ${lastcheck} &> /dev/null;then
SPECIES=$(diff ${IDFILE} ${lastcheck} \
diff --git a/scripts/spectrogram.php b/scripts/spectrogram.php
index e9d87bc..2ed5f72 100644
--- a/scripts/spectrogram.php
+++ b/scripts/spectrogram.php
@@ -1,8 +1,8 @@
Reboot
diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php
index 8ed2eee..eb18512 100644
--- a/scripts/todays_detections.php
+++ b/scripts/todays_detections.php
@@ -3,7 +3,7 @@ ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
-$db = new SQLite3('/home/pi/BirdNET-Pi/scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
+$db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
if($db == False){
echo "Database is busy";
header("refresh: 0;");
diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh
index 50823d3..da7d4c4 100755
--- a/scripts/uninstall.sh
+++ b/scripts/uninstall.sh
@@ -2,7 +2,7 @@
# Uninstall script to remove everything
#set -x # Uncomment to debug
trap 'rm -f ${TMPFILE}' EXIT
-my_dir=/home/pi/BirdNET-Pi/scripts
+my_dir=$HOME/BirdNET-Pi/scripts
source /etc/birdnet/birdnet.conf &> /dev/null
SCRIPTS=($(ls -1 ${my_dir}) ${HOME}/.gotty)
set -x
diff --git a/scripts/update_birdnet.sh b/scripts/update_birdnet.sh
index e8e83c4..970dd04 100755
--- a/scripts/update_birdnet.sh
+++ b/scripts/update_birdnet.sh
@@ -2,14 +2,12 @@
# Update BirdNET-Pi
source /etc/birdnet/birdnet.conf
trap 'exit 1' SIGINT SIGHUP
-USER=pi
-HOME=/home/pi
my_dir=${HOME}/BirdNET-Pi/scripts
-sudo -u${USER} git -C /home/pi/BirdNET-Pi stash
-sudo -u${USER} git -C /home/pi/BirdNET-Pi pull -f
+sudo -u${USER} git -C $my_dir/BirdNET-Pi stash
+sudo -u${USER} git -C $my_dir/BirdNET-Pi pull -f
sudo systemctl daemon-reload
-sudo -u${USER} git -C /home/pi/BirdNET-Pi stash pop
+sudo -u${USER} git -C $my_dir/BirdNET-Pi stash pop
sudo ln -sf $my_dir/* /usr/local/bin/
if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf;then
sudo -u${USER} echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf
diff --git a/scripts/update_caddyfile.sh b/scripts/update_caddyfile.sh
index c0f0e3e..4926d13 100755
--- a/scripts/update_caddyfile.sh
+++ b/scripts/update_caddyfile.sh
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
source /etc/birdnet/birdnet.conf
-USER=pi
-HOME=/home/pi
-my_dir=/home/pi/BirdNET-Pi/scripts
+my_dir=$HOME/BirdNET-Pi/scripts
set -x
[ -d /etc/caddy ] || mkdir /etc/caddy
if [ -f /etc/caddy/Caddyfile ];then
diff --git a/scripts/update_species.sh b/scripts/update_species.sh
index eb59741..3989e73 100755
--- a/scripts/update_species.sh
+++ b/scripts/update_species.sh
@@ -2,4 +2,4 @@
# Update the species list
#set -x
source /etc/birdnet/birdnet.conf
-sqlite3 /home/pi/BirdNET-Pi/scripts/birds.db "SELECT DISTINCT(Com_Name) FROM detections" | sort > ${IDFILE}
+sqlite3 $HOME/BirdNET-Pi/scripts/birds.db "SELECT DISTINCT(Com_Name) FROM detections" | sort > ${IDFILE}
diff --git a/scripts/write_config.sh b/scripts/write_config.sh
index 15bfa31..6d66b2a 100755
--- a/scripts/write_config.sh
+++ b/scripts/write_config.sh
@@ -1,6 +1,6 @@
#!/usr/bin/bash
# Writes variables to config file
-birdnetpi_dir=/home/pi/BirdNET-Pi
+birdnetpi_dir=$HOME/BirdNET-Pi
birders_conf=${birdnetpi_dir}/Birders_Guide_Installer_Configuration.txt
sed -i s/'^LATITUDE=$'/"LATITUDE=${new_lat}"/g ${birders_conf}
sed -i s/'^LONGITUDE=$'/"LONGITUDE=${new_lon}"/g ${birders_conf}
diff --git a/templates/bashrc b/templates/bashrc
index f5a93a8..7c0a0d8 100644
--- a/templates/bashrc
+++ b/templates/bashrc
@@ -113,7 +113,8 @@ if ! shopt -oq posix; then
fi
cd ~/BirdNET-Pi
function remove() {
- find /home/pi/BirdSongs -iname *${1}* -exec rm -drfv {} +
+ source /etc/birdnet/birdnet.conf
+ find $RECS_DIR -iname *${1}* -exec rm -drfv {} +
}
alias rerc="source ~/.bashrc"
alias vimrc="vim ~/.bashrc"
diff --git a/templates/cleanup.cron b/templates/cleanup.cron
index 42e5a26..4fb2fec 100644
--- a/templates/cleanup.cron
+++ b/templates/cleanup.cron
@@ -1,6 +1,6 @@
#birdnet
-*/5 * * * * pi /usr/local/bin/disk_check.sh &> /dev/null
+*/5 * * * * $USER /usr/local/bin/disk_check.sh &> /dev/null
#birdnet
-*/3 * * * * pi /usr/local/bin/cleanup.sh &> /dev/null
+*/3 * * * * $USER /usr/local/bin/cleanup.sh &> /dev/null
#birdnet
-@reboot pi /usr/local/bin/cleanup.sh &> /dev/null
+@reboot $USER /usr/local/bin/cleanup.sh &> /dev/null