27 lines
519 B
Bash
Executable File
27 lines
519 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SRC="${1:-}"
|
|
VOL="${2:-0.9}"
|
|
|
|
SNAP_IP="127.0.0.1"
|
|
SNAP_PORT="4953"
|
|
|
|
if [[ -z "$SRC" ]]; then
|
|
echo "Usage: $0 <file.wav|http(s)://...> [vol]"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$SRC" =~ ^https?:// ]]; then
|
|
curl -sL "$SRC" | \
|
|
sox -t wav - \
|
|
-t raw -r 48000 -c 2 -b 16 -e signed-integer - \
|
|
vol "$VOL" | \
|
|
nc -q 1 "$SNAP_IP" "$SNAP_PORT"
|
|
else
|
|
sox "$SRC" \
|
|
-t raw -r 48000 -c 2 -b 16 -e signed-integer - \
|
|
vol "$VOL" | \
|
|
nc -q 1 "$SNAP_IP" "$SNAP_PORT"
|
|
fi
|