如何为say'下载新语音;s函数与AppleScript?
我正在搜索一种方法,在系统首选项上安装不同的声音(确切地说是2种)。 这些声音是“亚历克斯”代表英国声音,“托马斯”代表法国声音 我直接用console进行了尝试,但没有成功,这就是为什么我转向AppleScript语言,但我从未使用过这种语言 我现在的代码是如何为say'下载新语音;s函数与AppleScript?,applescript,Applescript,我正在搜索一种方法,在系统首选项上安装不同的声音(确切地说是2种)。 这些声音是“亚历克斯”代表英国声音,“托马斯”代表法国声音 我直接用console进行了尝试,但没有成功,这就是为什么我转向AppleScript语言,但我从未使用过这种语言 我现在的代码是 set osver to system version of (system info) if osver is equal to "10.6.8" then display dialog ("Downloading voices
set osver to system version of (system info)
if osver is equal to "10.6.8" then
display dialog ("Downloading voices is only available in OS X Lion and higher")
else
tell application "System Preferences"
activate
reveal (pane id "com.apple.preference.speech")
end tell
try
tell application "System Events"
click radio button 2 of tab group 1 of window 1 of process "System Preferences"
repeat until (exists pop up button of tab group 1 of window 1 of process "System Preferences")
delay 2
end repeat
delay 2
click pop up button 1 of tab group 1 of window 1 of process "System Preferences"
delay 2
click menu item -1 of menu 1 of pop up button of tab group 1 of window 1 of process "System Preferences"
delay 2
end tell
on error
display dialog ("An error happend")
end try
end if
这个程序正在打开语音窗口,但无论我输入什么索引,每次都会出现显示对话框
如果您有其他想法下载这些声音,或者如果您能帮助我了解哪些不起作用,我将不胜感激。这在10.9中对我起到了作用:
tell application "System Preferences"
reveal anchor "TTS" of pane id "com.apple.preference.speech"
activate
end tell
tell application "System Events" to tell window 1 of process "System Preferences"
tell pop up button 1 of tab group 1
click
click menu item "Customize..." of menu 1
end tell
delay 1
repeat with r in UI element 1 of rows of table 1 of scroll area 1 of sheet 1
if exists static text 1 of r then
if {"Alex", "Thomas"} contains value of static text 1 of r then
if value of checkbox 1 of r is 0 then click checkbox 1 of r
end if
end if
end repeat
click button "OK" of sheet 1
end tell
不过,运行脚本需要几秒钟。哪一个“显示对话框始终显示”?错误是什么?它在这里为我工作在10.7在定制。。。纸张已打开。您只需要深入到它和它的表中,单击相应的复选框。是的,错误显示对话框出现。。。每次我修改此行时,单击“系统首选项”窗口1的选项卡组1的弹出按钮的菜单1的菜单项-1,我都会收到错误消息…请尝试在错误消息编号num\n显示对话框(“发生错误:”&msg&“#”&num)中将错误块更改为此
)\n结束尝试
查看发生了什么。同时尝试按名称寻址菜单项:例如,单击菜单项“自定义…”
确定,因此我修改了错误块,并通过菜单“自定义…”或-1“发生错误:'系统事件出错:菜单项“自定义…”收到此消息。。。进程“系统首选项”窗口1的选项卡组1的弹出按钮的菜单1不理解“单击”消息。#-1708“当我不再要求单击时,为什么会出现此消息?(我知道我的代码停在这里,在打开“自定义”后,我不要求他再执行任何操作,对吗?)我刚刚抄送/抄送了您的代码,收到此消息System Events出现错误:无法获取进程“系统首选项”窗口1的工作表1。索引无效。请立即重试。我编辑了脚本以在工作表打开后添加延迟。好的,我已尝试添加延迟,但它不工作,您的代码正在工作,非常感谢。