DAQ announcer
Updated on Mon, 2024-07-01 11:56. Originally created by veprbl on 2024-06-30 09:22.
#!/bin/sh # Blame: Dmitry Kalinkin 06/29/2024 RELOAD="0" INIT="1" export PATH=$PATH:$PWD/jq-1.7.1/bin while true; do curl --silent 'https://online.star.bnl.gov/daq/export/daq/daq_iface.php?host=daqman.starp.bnl.gov&proto=1&port=35000&type=3&last='$RELOAD'&dummy=1719664650593' \ -X 'GET' \ -H 'Accept: */*' \ -H 'Sec-Fetch-Site: same-origin' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Accept-Language: en-US,en;q=0.9' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Host: online.star.bnl.gov' \ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15' \ -H 'Referer: https://online.star.bnl.gov/daq/export/daq/' \ -H 'Accept-Encoding: gzip, deflate, br' \ -H 'Connection: keep-alive' > json if [ $RELOAD = "$(jq '.cmd.now' json)" ]; then INIT="0" fi RELOAD="$(jq '.cmd.now' json)" jq '[ .log | to_entries[] | select(.key != "line_num") | [.key, .value[]] ] | transpose[] | select(.[3] == "CRITICAL" or .[3] == "CAUTION") | .[6]' json 2>/dev/null > out cat out if [ "x${INIT}" = "x0" ]; then if [ -s out ]; then pactl -- set-sink-volume 0 175% paplay mixkit-system-beep-buzzer-fail-2964.wav paplay mixkit-system-beep-buzzer-fail-2964.wav paplay mixkit-system-beep-buzzer-fail-2964.wav curl --quiet https://api.openai.com/v1/audio/speech \ -H "Authorization: Bearer <API TOKEN HERE>" \ -H "Content-Type: application/json" \ -d "$(cat out | tr "\n\r" " " | jq -R '{ "model": "tts-1", "response_format": "pcm", "input": ., "voice": "alloy" }')" \ --output example.pcm paplay --format s16le --rate 24000 --channels 1 --raw example.pcm pactl -- set-sink-volume 0 100% fi sleep 10 fi done
»
- veprbl's blog
- Login or register to post comments