AppleScript 脚本让 Mac 唱生日快乐歌
2013-10-24 11:33
232 查看
挺有意思的一篇文章,转载过来保存!
转载地址:http://lucifr.com/2012/02/11/make-your-mac-sing-happy-birthday-with-applescript/
AppleScript 脚本让 Mac 唱生日快乐歌
Lucifr 家中有个传统,每个家庭成员的生日都要买个蛋糕,然后全家围坐唱“祝你生日快乐”来对寿星表示祝贺(寿星本人也会像胖虎一样唱“祝我生日快乐”囧)。看来现在又多了个很 geek 的选项:让 Mac 来唱生日快乐歌。
方法如下:
•打开 AppleScript Editor.app(在“应用程序” ->“实用工具”里),粘贴以下代码:
Happy Birthday Song
1234567891011121314151617181920 set currentUser to long user name of (get system info)set firstName to first word of currentUserset lastName to last word of currentUserset 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} -- Eset 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 0end repeat
•现在点一下 Run 这个按钮,你应该能听到 Mac 在用“优美的声线”在给你唱歌了。这里 firstName 和 lastName 被设置为当前用户的名和姓。当然你也可以把前三行换成下面这样来自己指定姓名:
set firstName to "Lucifr"
set lastName to "Liu"
•此外如果对这个声音不感冒,可以修改倒数第二行的 Victoria 来指定用别的嗓音来唱,比如 Bad News、Bahh 什么的(笑)。自己到“系统选项”->“语音”->“文本至语音”->“系统嗓音”->“自定”里去找一个吧,各种性别和国籍,相信可以满足不同的取向和需求(有些太独特的需要单独下载)。
System Voice
•修改满意之后,我们可以把这个脚本起个名字保存一下。为了能在某人生日时自动播放给她/他个惊喜,我们再打开 iCal,设置个提醒:
iCal Happy Birthday
•收工~给你的朋友一个惊吓喜去吧~
转载地址:http://lucifr.com/2012/02/11/make-your-mac-sing-happy-birthday-with-applescript/
AppleScript 脚本让 Mac 唱生日快乐歌
Lucifr 家中有个传统,每个家庭成员的生日都要买个蛋糕,然后全家围坐唱“祝你生日快乐”来对寿星表示祝贺(寿星本人也会像胖虎一样唱“祝我生日快乐”囧)。看来现在又多了个很 geek 的选项:让 Mac 来唱生日快乐歌。
方法如下:
•打开 AppleScript Editor.app(在“应用程序” ->“实用工具”里),粘贴以下代码:
Happy Birthday Song
1234567891011121314151617181920 set currentUser to long user name of (get system info)set firstName to first word of currentUserset lastName to last word of currentUserset 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} -- Eset 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 0end repeat
•现在点一下 Run 这个按钮,你应该能听到 Mac 在用“优美的声线”在给你唱歌了。这里 firstName 和 lastName 被设置为当前用户的名和姓。当然你也可以把前三行换成下面这样来自己指定姓名:
set firstName to "Lucifr"
set lastName to "Liu"
•此外如果对这个声音不感冒,可以修改倒数第二行的 Victoria 来指定用别的嗓音来唱,比如 Bad News、Bahh 什么的(笑)。自己到“系统选项”->“语音”->“文本至语音”->“系统嗓音”->“自定”里去找一个吧,各种性别和国籍,相信可以满足不同的取向和需求(有些太独特的需要单独下载)。
System Voice
•修改满意之后,我们可以把这个脚本起个名字保存一下。为了能在某人生日时自动播放给她/他个惊喜,我们再打开 iCal,设置个提醒:
iCal Happy Birthday
•收工~给你的朋友一个惊吓喜去吧~
相关文章推荐
- Mac OS X下使用launchctl定时启动AppleScript脚本
- 从终端命令行运行 AppleScript 脚本
- mac下的应用程序发布 及 打包(Python写的脚本,可打包第三方库)
- 【工作文档】ifconfig 命令查找mac脚本例程一
- Mac OS X Shell 脚本和终端命令
- AppleScript脚本
- 再mac下建立shell脚本,并运行
- 第一个Mac shell 小脚本
- mac实用脚本
- Mac shell 小脚本开发(转)
- MAC 系统的启动过程和系统启动时运行shell 脚本
- ARP协议(ARP脚本抓取主机MAC的实现)
- Python脚本实现Mac开机自动语音播报天气
- Mac下给Wireshark添加Lua脚本
- linux下统计内网mac脚本
- 在mac上创建鼠标双击可执行的shell脚本
- mac下ipa自动编译脚本---自用
- mac设置开机启动脚本或应用
- Mac下如何建立双击可执行的脚本
- linux实用技巧:使用脚本获取活动网卡的mac地址