Use raw flac (#408)
* Use raw * clean not used * Add soundfile * Add soundfile * Update scripts/update_birdnet_snippets.sh Co-authored-by: Nachtzuster <Nachtzuster@users.noreply.github.com> --------- Co-authored-by: Nachtzuster <Nachtzuster@users.noreply.github.com>
This commit is contained in:
@@ -16,3 +16,4 @@ requests
|
|||||||
matplotlib
|
matplotlib
|
||||||
pillow
|
pillow
|
||||||
pyarrow==20.0.0
|
pyarrow==20.0.0
|
||||||
|
soundfile
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ if [ "$PY_VERSION" == 39 ] && [ "$tf_version" != "2.11.0" ] || [ "$PY_VERSION" !
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
ensure_python_package inotify inotify
|
ensure_python_package inotify inotify
|
||||||
|
ensure_python_package soundfile soundfile
|
||||||
|
|
||||||
if ! which inotifywait &>/dev/null;then
|
if ! which inotifywait &>/dev/null;then
|
||||||
ensure_apt_updated
|
ensure_apt_updated
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import glob
|
import glob
|
||||||
import gzip
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@@ -179,15 +178,14 @@ def bird_weather(file: ParseFileName, detections: [Detection]):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error("Error during FLAC conversion: %s", e)
|
log.error("Error during FLAC conversion: %s", e)
|
||||||
return
|
return
|
||||||
gzip_flac_data = gzip.compress(flac_data)
|
|
||||||
|
|
||||||
# POST soundscape to server
|
# POST soundscape to server
|
||||||
soundscape_url = (f'https://app.birdweather.com/api/v1/stations/'
|
soundscape_url = (f'https://app.birdweather.com/api/v1/stations/'
|
||||||
f'{conf["BIRDWEATHER_ID"]}/soundscapes?timestamp={file.iso8601}')
|
f'{conf["BIRDWEATHER_ID"]}/soundscapes?timestamp={file.iso8601}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.post(url=soundscape_url, data=gzip_flac_data, timeout=30,
|
response = requests.post(url=soundscape_url, data=flac_data, timeout=30,
|
||||||
headers={'Content-Type': 'application/octet-stream', 'Content-Encoding': 'gzip'})
|
headers={'Content-Type': 'audio/flac'})
|
||||||
log.info("Soundscape POST Response Status - %d", response.status_code)
|
log.info("Soundscape POST Response Status - %d", response.status_code)
|
||||||
sdata = response.json()
|
sdata = response.json()
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user