首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AppleScript语音识别服务器可监听任何响应

AppleScript语音识别服务器可监听任何响应
EN

Stack Overflow用户
提问于 2012-12-25 07:50:32
回答 2查看 2.1K关注 0票数 2

好的,目前,我有一个脚本,看起来像这样:

代码语言:javascript
复制
tell application "SpeechRecognitionServer"
    set theResponse to listen for {"Mark"} with prompt "What is your name?"
end tell

但是,我不希望它监听特定的关键字。我希望它从提示中收集语音数据,并将其转换为我可以存储在数据库中的字符串。

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

这个是可能的吗?现在,我只看到了监听关键字的选项,这对我试图实现的目标来说并不可取。

感谢您的帮助。

EN

回答 2

Stack Overflow用户

发布于 2013-04-09 22:49:00

代码语言:javascript
复制
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
票数 1
EN

Stack Overflow用户

发布于 2019-12-20 04:25:21

下面是我的QuickAction自动化脚本,用于打开对话框、开始口述、捕获输入并运行shell脚本将其转换为连字符文本,然后将该连字符文本插入到前台应用程序中。

您可能需要调整键盘快捷键才能开始听写,该快捷键位于首选项->键盘->听写下。

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

代码语言:javascript
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14026565

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档