好的,目前,我有一个脚本,看起来像这样:
tell application "SpeechRecognitionServer"
set theResponse to listen for {"Mark"} with prompt "What is your name?"
end tell但是,我不希望它监听特定的关键字。我希望它从提示中收集语音数据,并将其转换为我可以存储在数据库中的字符串。
因此,例如,用户将被提示语音问题“您的名字是什么?”。然后,他们会说出自己的名字,比如"Mark",语音识别服务器将捕获该输入,将其转换为文本,并将其存储为变量(userName = theResponse;)
这个是可能的吗?现在,我只看到了监听关键字的选项,这对我试图实现的目标来说并不可取。
感谢您的帮助。
发布于 2013-04-09 22:49:00
tell application "Finder"
say "Which application would you like me to open?" using "Alex"
end tell
set theOpen to text returned of (display dialog "Press the 'fn' key twice and speak!" default answer "" buttons {"Cancel", "Ok"} default button 2)
tell application "Finder"
say "Ok! I will open " & theOpen & " for you" using "Alex"
end tell
tell application theOpen
activate
end tell发布于 2019-12-20 04:25:21
下面是我的QuickAction自动化脚本,用于打开对话框、开始口述、捕获输入并运行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 runhttps://stackoverflow.com/questions/14026565
复制相似问题