Skip to content

Instantly share code, notes, and snippets.

@WorldDownTown
Last active May 7, 2020 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WorldDownTown/cb1fb7dfe64302d08dc2ac2279fe02c4 to your computer and use it in GitHub Desktop.
Save WorldDownTown/cb1fb7dfe64302d08dc2ac2279fe02c4 to your computer and use it in GitHub Desktop.
volume-configured say command
#!/bin/sh
# ~/say_with_volume.sh "hello world" # default volume is 20
# ~/say_with_volume.sh "hello world" 30
volume=`osascript -e "output volume of (get volume settings)"`
default_volume=20
say_volume=$2
if [ $volume = "0" ]; then
# If the volume is zero, the script doesn't do anything.
exit 0
fi
if [ "${say_volume}" = "" ]; then
osascript -e "set Volume output volume ${default_volume}"
else
osascript -e "set Volume output volume ${say_volume}"
fi
say -v Samantha "${1}"
osascript -e "set Volume output volume ${volume}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment