#!/bin/bash # say_out_loud.sh # Usage: ./say_out_loud.sh "message to say" MESSAGE="$1" # Set output to built-in speakers — comment this line if not needed default_output="$(system_profiler SPAudioDataType | grep -B 5 'Built-in Output' | grep 'Device ID' | awk -F ": " '{print $2}' | head -n1)" if [[ -n "$default_output" ]]; then SwitchAudioSource -s "$default_output" 2>/dev/null fi # Set system volume to 80% osascript -e 'set volume output volume 80' # Play chime afplay /System/Library/Sounds/Glass.aiff # Speak the message (default voice) say "$MESSAGE"