Create say-out-loud skill: chime, built-in speakers, sets volume, speaks answer

This commit is contained in:
Adolfo Reyna
2026-02-14 21:27:50 -05:00
parent d1676d11ef
commit 1b75c79179
2 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#!/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"