【发布时间】:2011-06-26 14:36:20
【问题描述】:
是否可以使用 AppleScript 停止 Mac 当前正在生成(或已排队)的任何语音?
我基本上是在寻找 AppleScript “say” 命令的反义词。
【问题讨论】:
标签: applescript text-to-speech speech
是否可以使用 AppleScript 停止 Mac 当前正在生成(或已排队)的任何语音?
我基本上是在寻找 AppleScript “say” 命令的反义词。
【问题讨论】:
标签: applescript text-to-speech speech
试试这个,一个完整的 AppleScript 解决方案(不需要 shell):
-- say some text asynchronously
say "Hello, world!" waiting until completion no
-- delay 1 second before stopping
delay 1
-- stop text by saying nothing, which stops current speech
say "" with stopping current speech
【讨论】:
with stopping current speech,但没有成功,感谢您指出waiting until completion no 选项。
要停止演讲,您必须停止运行演讲的进程。当您说“Mac 当前正在生成的任何语音”时,这很难做到,因为可能有不同的过程产生语音。你必须想办法确定是什么产生了演讲。
这是我生成语音的示例,因此我知道要终止哪个进程以使语音停止。
set theText to "Is it possible to stop any speech that the Mac is currently producing (or has queued) using an AppleScript? I'm basically looking for the opposite of the AppleScript \"say\" command."
set thePID to do shell script "say " & quoted form of theText & " > /dev/null 2>&1 & echo $!"
delay 1
do shell script "kill " & thePID
【讨论】: