Tag ambient audio chunks with current OpenWeather conditions
Adds weather-tag.sh, a small failure-safe helper that queries OpenWeather's free "Current weather" endpoint and prints one tag from a fixed vocabulary (thunderstorm, rain, rainshower, snow, snowstorm, fog, windy, cloudy, clear) or nothing on any failure. ambient-record.sh calls it just before each 30-minute chunk so the filename reflects conditions at the moment of capture, e.g. east-08-30-00-thunderstorm.m4a east-12-00-00-clear.m4a A foggy dawn no longer mislabels the sunny afternoon files. Off by default. Enable with WEATHER_ENABLED=true and an OPENWEATHER_API_KEY entry in .env; missing key / API error / disabled toggle all fall through to the un-tagged filename, never blocking the recorder.
This commit is contained in:
+11
-1
@@ -50,7 +50,17 @@ while true; do
|
||||
mkdir -p "$dir"
|
||||
|
||||
timestamp=$(date +%H-%M-%S)
|
||||
outfile="$dir/${CAM}-${timestamp}.m4a"
|
||||
|
||||
# Weather tag for THIS chunk — queried right before recording so the
|
||||
# filename reflects conditions at the time of capture, not earlier in the
|
||||
# day. weather-tag.sh prints empty on disabled / missing key / API error,
|
||||
# so the un-tagged filename is the safe fallback.
|
||||
weather_tag=$("$SCRIPT_DIR/weather-tag.sh" 2>/dev/null || true)
|
||||
if [ -n "$weather_tag" ]; then
|
||||
outfile="$dir/${CAM}-${timestamp}-${weather_tag}.m4a"
|
||||
else
|
||||
outfile="$dir/${CAM}-${timestamp}.m4a"
|
||||
fi
|
||||
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Recording → $outfile (${CHUNK}s)"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user