Compare commits

...

5 Commits

6 changed files with 64 additions and 10 deletions

View File

@ -33,7 +33,7 @@ BRANCH=dev ./install.sh
```bash
sudo apt-get update
sudo apt-get install python3-dev python3-pip
sudo apt-get install python3-dev python3-pip python3-venv
sudo pip3 install --upgrade pip
```
@ -272,3 +272,28 @@ sudo crontab -e
```
(This updates the certicates every first day of the month, feel free to adapt to your needs.)
## Setup ttyd to stream audio to webapp
Change to a dedicated folder, build and install ttyd:
```bash
cd /opt
sudo wget wget https://github.com/tsl0922/ttyd/releases/download/1.7.1/ttyd.x86_64 # Change to your architecture and get last version
sudo mv ttyd.x86_64 ttyd
sudo chmod +x ttyd
```
Set up birdnet_ttyd systemd service to start as a daemon:
```bash
# Copy service template
sudo cp ./daemon/systemd/templates/birdnet_ttyd.service /etc/systemd/system/birdnet_ttyd.service
# Edit template and adapt placeholders
sudo vim /etc/systemd/system/birdnet_ttyd.service
# Enable and start ttyd service
sudo systemctl daemon-reload
sudo systemctl enable --now birdnet_ttyd.service
```
Then go to [https://birdnet.lan/ttyd](https://birdnet.lan/ttyd) and start streaming logs.

View File

@ -11,7 +11,8 @@ CONFIG = {
"readings": 10,
"palette": "Greens",
"db": "./var/db.sqlite",
"date": "2022-08-14"
"date": datetime.now().strftime("%Y-%m-%d")
# "date": "2022-08-15"
}
db = sqlite3.connect(CONFIG['db'])
@ -27,17 +28,20 @@ df['date'] = df['date'].astype(str)
df_on_date = df[df['date'] == CONFIG['date']]
top_on_date = (df_on_date['common_name'].value_counts()[:CONFIG['readings']])
if top_on_date.empty:
print("No observations on {}".format(CONFIG['date']))
exit()
df_top_on_date = df_on_date[df_on_date['common_name'].isin(top_on_date.index)]
# Create a figure with 2 subplots
fig, axs = plt.subplots(1, 2, figsize=(15, 4), gridspec_kw=dict(
width_ratios=[3, 6]))
fig, axs = plt.subplots(1, 2, figsize=(20, 5), gridspec_kw=dict(
width_ratios=[2, 6]))
plt.subplots_adjust(left=None, bottom=None, right=None,
top=None, wspace=0, hspace=0)
# Get species frequencies
frequencies_order = pd.value_counts(df['common_name']).iloc[:CONFIG['readings']].index
frequencies_order = pd.value_counts(df_top_on_date['common_name']).iloc[:CONFIG['readings']].index
# Get min max confidences
confidence_minmax = df_top_on_date.groupby('common_name')['confidence'].max()
confidence_minmax = confidence_minmax.reindex(frequencies_order)
@ -83,9 +87,8 @@ for _, spine in plot.spines.items():
plot.set(ylabel=None)
plot.set(xlabel="Hour of day")
fig.subplots_adjust(top=0.9)
plt.suptitle(f"Top {CONFIG['readings']} species (Updated on {datetime.now().strftime('%Y/%m-%d %H:%M')})")
plt.suptitle(f"Top {CONFIG['readings']} species on {CONFIG['date']}", fontsize=14)
plt.text(15, 11, f"(Updated on {datetime.now().strftime('%Y/%m-%d %H:%M')})")
plt.savefig(f"./var/charts/chart_{CONFIG['date']}.png", dpi=300)
plt.close()

View File

@ -0,0 +1,14 @@
[Unit]
Description=BirdNET-stream logs
After=syslog.target
After=network.target
[Service]
User=<USER>
Group=<GROUP>
ExecStart=/opt/ttyd -p 7681 -c birdnet:secret -t disableReconnect=true --readonly journalctl -feu birdnet_\*
Restart=always
Type=simple
[Install]
WantedBy=multi-user.target

View File

@ -5,7 +5,7 @@ set -e
DEBUG=${DEBUG:-0}
REQUIREMENTS="git wget ffmpeg python3 python3-pip python3-dev python3-venv gzip"
REQUIREMENTS="git wget ffmpeg python3 python3-pip python3-dev python3-venv zip unzip sqlite3"
REPOSITORY=${REPOSITORY:-https://github.com/UncleSamulus/BirdNET-stream.git}
BRANCH=${BRANCH:-main}
WORKDIR="$(pwd)/BirdNET-stream"
@ -206,6 +206,7 @@ install_config() {
update_permissions() {
debug "Updating permissions (may not work properly)"
cd $WORKDIR
sudo chown -R $USER:birdnet "$WORKDIR"
sudo chown -R $USER:birdnet "$CHUNK_FOLDER"
sudo chmod -R 755 "$CHUNK_FOLDER"

1
www/.gitignore vendored
View File

@ -8,6 +8,7 @@
/public/bundles/
/var/
/vendor/
yarn.lock
###< symfony/framework-bundle ###
###> symfony/webpack-encore-bundle ###

View File

@ -51,6 +51,16 @@ server {
proxy_pass http://localhost:8000/stream;
}
location ~ ^/ttyd(.*)$ {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:7681/$1;
}
access_log /var/log/nginx/birdnet/birdnet-access.log;
error_log /var/log/nginx/birdnet/birdnet-error.log error;
}