making changes to accomodate removing the pi user

This commit is contained in:
mcguirepr89
2022-04-11 10:16:54 -04:00
parent 341cc17264
commit 023b68f386
39 changed files with 167 additions and 191 deletions
+9 -10
View File
@@ -1,4 +1,3 @@
#!/home/pi/BirdNET-Pi/birdnet/bin/python3
import socket
import threading
import os
@@ -44,7 +43,7 @@ except:
# Open most recent Configuration and grab DB_PWD as a python variable
with open('/home/pi/BirdNET-Pi/thisrun.txt', 'r') as f:
with open('/home/*/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 +58,7 @@ 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)
myinterpreter = tflite.Interpreter(model_path='/home/*/BirdNET-Pi/model/BirdNET_6K_GLOBAL_MODEL.tflite',num_threads=2)
myinterpreter.allocate_tensors()
# Get input and output tensors.
@@ -73,7 +72,7 @@ def loadModel():
# Load labels
CLASSES = []
with open('/home/pi/BirdNET-Pi/model/labels.txt', 'r') as lfile:
with open('/home/*/BirdNET-Pi/model/labels.txt', 'r') as lfile:
for line in lfile.readlines():
CLASSES.append(line.replace('\n', ''))
@@ -170,11 +169,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('/home/*/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 +258,8 @@ def handle_client(conn, addr):
args = type('', (), {})()
args.i = '/home/pi/test.wav'
args.o = '/home/pi/test.wav.csv'
args.i = '/home/*/test.wav'
args.o = '/home/*/test.wav.csv'
args.birdweather_id = '99999'
args.include_list = 'null'
args.exclude_list = 'null'
@@ -355,7 +354,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('/home/*/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 +380,7 @@ def handle_client(conn, addr):
#Connect to SQLite Database
try:
con = sqlite3.connect('/home/pi/BirdNET-Pi/scripts/birds.db')
con = sqlite3.connect('/home/*/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))