commit f44814ac19100c6f1d7c2957ad0eba321aa16160
parent ff07d7aaf81605475cf753879f6ec8e96577b861
Author: breadcat <breadcat@users.noreply.github.com>
Date: Fri, 17 Jul 2026 10:48:57 +0100
Basename program, inline models and hardcode common arguments
Diffstat:
1 file changed, 11 insertions(+), 28 deletions(-)
diff --git a/scripts/pbx.nix b/scripts/pbx.nix
@@ -6,15 +6,16 @@ let
set -euo pipefail
usage() {
+local prog=''${0##*/}
cat <<EOF
Usage:
- $0 <model> <input> [output] [--volume N]
+ $prog <model> <input> [output] [--volume N]
Examples:
- $0 samsung greeting.mp3
- $0 samsung greeting.mp3 output.wav
- $0 gamma prompt.flac --volume 0.8
- $0 webex prompt.wav output.wav --volume 0.75
+ $prog samsung greeting.mp3
+ $prog samsung greeting.mp3 output.wav
+ $prog gamma prompt.flac --volume 0.8
+ $prog webex prompt.wav output.wav --volume 0.75
EOF
exit 1
}
@@ -60,25 +61,11 @@ fi
exit 1
}
-COMMON_ARGS=(
- -ar 8000
- -ac 1
-)
-
case "$MODEL" in
- samsung|3cx|webex)
- CODEC_ARGS=(-codec:a pcm_s16le -ab 128k)
- ;;
- lg-emg|lg-ucp|panasonic|gamma)
- CODEC_ARGS=(-codec:a pcm_mulaw -ab 64k)
- ;;
- lg-hosted)
- CODEC_ARGS=(-codec:a pcm_s16le -ab 64k)
- ;;
- *)
- echo "Unknown model '$MODEL'"
- exit 1
- ;;
+ samsung|3cx|webex) CODEC_ARGS=(-codec:a pcm_s16le -ab 128k) ;;
+ lg-emg|lg-ucp|panasonic|gamma) CODEC_ARGS=(-codec:a pcm_mulaw -ab 64k) ;;
+ lg-hosted) CODEC_ARGS=(-codec:a pcm_s16le -ab 64k) ;;
+ *) echo "Unknown model '$MODEL'" && exit 1 ;;
esac
FFMPEG_ARGS=()
@@ -105,11 +92,7 @@ if [[ "$(realpath "$INPUT")" == "$(realpath -m "$OUTPUT")" ]]; then
echo "Original renamed to $BACKUP"
fi
-${pkgs.ffmpeg}/bin/ffmpeg -i "$INPUT" \
- "''${CODEC_ARGS[@]}" \
- "''${COMMON_ARGS[@]}" \
- "''${FFMPEG_ARGS[@]}" \
- "$OUTPUT"
+${pkgs.ffmpeg}/bin/ffmpeg -i "$INPUT" -ar 8000 -ac 1 "''${CODEC_ARGS[@]}" "''${FFMPEG_ARGS[@]}" "$OUTPUT"
echo "Created $OUTPUT"