2

AppleScript を使用して、Mac が現在生成している (またはキューに入れている) 音声を停止することはできますか?

私は基本的に、AppleScript の「say」コマンドの反対を探しています。

4

2 に答える 2

3

Try this, a complete AppleScript solution (no shell required):

-- 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 に答える