AppleScript语音识别服务器以侦听任何响应

AppleScript语音识别服务器以侦听任何响应,applescript,Applescript,好的,目前,我有一个脚本如下所示: tell application "SpeechRecognitionServer" set theResponse to listen for {"Mark"} with prompt "What is your name?" end tell 然而,我不希望它听一个特定的关键字。我想让它从提示中收集语音数据,并将其转换为字符串,以便存储在数据库中 因此,例如,用户会被提示一个口头问题“你叫什么名字?”。然后,他们会说出自己的名字,说“Mark”,

好的,目前,我有一个脚本如下所示:

tell application "SpeechRecognitionServer"
    set theResponse to listen for {"Mark"} with prompt "What is your name?"
end tell
然而,我不希望它听一个特定的关键字。我想让它从提示中收集语音数据,并将其转换为字符串,以便存储在数据库中

因此,例如,用户会被提示一个口头问题“你叫什么名字?”。然后,他们会说出自己的名字,说“Mark”,语音识别服务器会捕获输入,将其转换为文本,并将其存储为变量(userName=theResponse;)

这可能吗?现在我只看到了听关键词的选项,这对于我想要实现的目标来说是不可取的


谢谢您的帮助。

正如加勒特所说,我所做的就是使用对话框输入文本。默认的语音命令键是双击“fn”键


这是我的QuickAction Automator脚本,用于打开对话框、开始听写、捕获输入并运行shell脚本将其转换为连字号文本,然后将该连字号文本插入前台应用程序

您可能需要调整键盘快捷键以开始听写,它位于“首选项->键盘->听写”下

QuickActions将进入所有应用程序的“服务”菜单。然后,可以在“键盘首选项”下为该新服务分配键盘快捷键。然后我在辅助功能键盘上做一个按钮来运行快捷键

on run {input, parameters}

ignoring application responses
    tell application "System Events"
        -- send keystrokes to start dictation.
        -- delay 1
        keystroke "`" using {control down, command down}
    end tell
end ignoring

-- capture input
set theResponse to text returned of (display dialog "Input:" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue")

-- convert to hyphenated
set newOutput to do shell script "ruby -e 'puts ARGV.join(\"-\").downcase' " & theResponse


    return newOutput
end run


实际上,您可以使用Mountain Lion(10.8.x)中的听写选项,并使用显示对话框命令创建一个文本字段。但至于你想要什么,嗯,我也在想同样的事情。打开对话开始听写是件小事。。。当对话框打开时,如何让听写开始,以便speach->文本进入对话框?
on run {input, parameters}

ignoring application responses
    tell application "System Events"
        -- send keystrokes to start dictation.
        -- delay 1
        keystroke "`" using {control down, command down}
    end tell
end ignoring

-- capture input
set theResponse to text returned of (display dialog "Input:" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue")

-- convert to hyphenated
set newOutput to do shell script "ruby -e 'puts ARGV.join(\"-\").downcase' " & theResponse


    return newOutput
end run