Mac 內建「腳本編輯器」執行 AppleScript,可讓系統語音合成(Siri 前身)唱生日歌,支援自訂姓名、語速、音高、聲音人格。

Spotlight 搜尋「Script Editor」或「腳本編輯器」開啟。

set currentUser to long user name of (get system info)
set firstName to first word of currentUser
set lastName to last word of currentUser
set noteValues to {56, 56, 58, 56, 61, 60, 50, 56, 56, 58, 56, 63, 61, 50, 56, 56, 68, 65, 61, 60, 58, 50, 66, 66, 65, 61, 63, 61} -- F 調
-- set noteValues to {65, 65, 67, 65, 70, 69, 60, 65, 65, 67, 65, 72, 70, 60, 65, 65, 77, 74, 70, 69, 67, 60, 75, 75, 74, 70, 72, 70} -- D 調
-- set noteValues to {55, 55, 57, 55, 60, 59, 50, 55, 55, 57, 55, 62, 60, 50, 55, 55, 67, 64, 60, 59, 57, 50, 65, 65, 64, 60, 62, 60} -- E 調
set syllables to {"hap", "p", "birth", "day", "to", "you", "[[slnc 500]]", "hap", "p", "birth", "day", "to", "you", "[[slnc 500]]", "hap", "p", "birth", "day", "dear", firstName, lastName, "[[slnc 500]]", "hap", "p", "birth", "day", "to", "you"}
repeat with i from 1 to the length of noteValues
set thisValue to item i of noteValues
set thisSyllable to item i of syllables
if length of thisSyllable is less than 3 then
set speakingRate to 220
else
set speakingRate to 100
end if
say thisSyllable pitch thisValue using "Victoria" speaking rate speakingRate modulation 0
end repeat
點選工具列「執行」(▶️)按鈕,Mac 即刻唱出生日歌。

將前三行替換為:
set firstName to "David"
set lastName to "Chen"
建議使用英文名,中文發音在舊版語音引擎可能不準。
修改倒數第二行 using "Victoria":

noteValues 陣列為 MIDI 音高數值(60 = 中央 C),三組預設對應 F/D/E 大調speakingRate:短音節 220、長音節 100,可自行微調[[slnc 500]]:500ms 靜默間隔,可調整節奏say -o birthday.aiff -f script.txt幾行代碼,讓 Mac 成為最貼心的生日歌手。