2

是否可以使用 AppleScript 停止 Mac 当前正在生成(或已排队)的任何语音?

我基本上是在寻找与 AppleScript “say” 命令相反的东西。

4

2 回答 2

3

试试这个,一个完整的 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
于 2013-01-17T01:21:22.350 回答
1

要停止演讲,您必须停止运行演讲的进程。当您说“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
于 2011-02-16T05:38:51.717 回答