|
|
#1 |
|
Prospect
Join Date: Mar 2006
Posts: 10
|
I just discovered the magic that is speakable items, and I can't help but love the idea of adressing my computer by name and commanding it to do something.
Now, My question is this: Is there a way to make the computer reply to keywords with predetermined answers? It's kinda dorky, but since i use the command line, when I say "computer" I'd like it to respond with "Yes?" or something. If this is too far out, let me know, but I have a feeling someone figured this out. Thanks in advance. |
|
|
|
|
|
#2 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
Here's a sample AppleScript (try running it in Script Editor) from an Apple document that seems temporarily unavailable but can be accessed from Google's cache:
http://72.14.203.104/search?q=cache:...&client=safari Code:
tell application "SpeechRecognitionServer"
local theResultstring, helpLanguageModel, choicesLanguageModel
set helpLanguageModel to {"help", "help me", "what can i say"}
set choicesLanguageModel to {"iMac", "iBook", "PowerMac"}
set thePrompt to "What is your [[emph +]] favorite Macintosh?"
try
set theResultstring to listen for choicesLanguageModel & helpLanguageModel with prompt thePrompt giving up after 30
if theResultstring is "iMac" then
say "I like that [[emph +]] too!"
else if theResultstring is "iBook" then
say "The iBook is [[emph +]] cool"
else if theResultstring is "PowerMac" then
say "[[emph +]]Wow. You must be a professional."
else if theResultstring is in helpLanguageModel then
tell me to doHelp()
end if
end try
end tell
on doHelp()
say "I would really like to help you but I cannot."
end doHelp
__________________
hayne.net/macosx.html |
|
|
|
|
|
#3 |
|
Hall of Famer
Join Date: Nov 2004
Posts: 3,818
|
Hmmm...how long can it be before someone writes Marvin the Paranoid Android, "Dark Star" bomb, or HAL 9000 scripts?
"Open the keychain, Hal......Hal......open the keychain..." |
|
|
|
|
|
#4 |
|
Prospect
Join Date: Mar 2006
Posts: 10
|
Hayne, thanks for your response, though I'm not quite savvy enough to know whether or not this really answers my question. I basically want verbal commands to incite a spoken response from the speach feedback, such as it does during an error, only, obivously, editable to my liking
|
|
|
|
|
|
#5 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
I'm not familiar enough with the standard speakable items to know how easy it would be to hook this sort of thing up. But I vaguely recall that they make use of AppleScript, so it should be possible with some investigation.
In any case, the script I showed above does work (on my 10.4.5 machine) and so it could provide a base for writing your own script that would do whatever you want. The script above only speaks back to you in response to your speech input but it could do anything that is possible in AppleScript - e.g. opening an application, opening a document, etc. Of course you would need to learn AppleScript to do this. There are lots of introductory tutorials available and lots of people on these forums who know a lot about AppleScript and are usually happy to help if you describe what you want to do. To get started, just open Script Editor (it's under /Applications/AppleScript) and copy & paste the above script into it, then press "Run".
__________________
hayne.net/macosx.html |
|
|
|
|
|
#6 |
|
Prospect
Join Date: Mar 2006
Posts: 10
|
I would like write a script (or scripts) that would do two things, though I know nothing about writing scripts.
I recently discovered speakable commands, and I would like to script responses by the speach feedback beyond the standard "whiit" or "speak command acknowledgement". What I was hoping to acheive would be a a command that would simply result in a spoken phrase such as "thank you" and it's response, "you're welcome", spoken by the computer. the second response i was hoping to script would be a single response at command recognition, but only when the keyword is spoken, such as "computer" and it's response "yes dave?" with no further response. These scripts are clearly useless beyond simple amusement, but having little knowledge of writing code and scripts I figure this would be a good way to start. I was also wondering how these scripts could be saved/exported to a speakable command so that they would operate soleley in that environment. Thanks for any advice/scripts that you guys could share with me! |
|
|
|
|
|
#7 |
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
BehindthePlan:
I merged your new thread into this existing one. Let's keep it to the one thread. I'll move this thread into the Developers forum since that's what you seem to want. But to get people to help you, you are going to need to make a start on it yourself. Start by searching for docs on AppleScript, on Speakable Items, etc, and read it all, then try some experiments with Script Editor in making your own scripts etc. Show us your scripts, tell us what works and what doesn't and then people will help.
__________________
hayne.net/macosx.html Last edited by hayne; 03-15-2006 at 09:25 PM. |
|
|
|
|
|
#8 |
|
Prospect
Join Date: Mar 2006
Posts: 10
|
Thanks, as you can tell I'm new at this, and I appreciate you're help
|
|
|
|
|
|
#9 |
|
MVP
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
|
From what I can see, Haynes script idea will work for the responses with the spoken keyword before command.
But the "Thank You" - "Your welcome" part has no keyword So the computer would ignore the "Thank You" I not sure if its possible to have two Keywords. If you could then You could use "Thank You" as one Or you could just say "Computer, Thank You" but it does not have the same feel. |
|
|
|
|
|
#10 |
|
Triple-A Player
Join Date: Nov 2002
Location: Massachusetts
Posts: 202
|
Actually, I had a similar set-up back when I was using OS 9.
You can set the speech recognition to keep listening for commands for 15/30 seconds after the last spoken keyword. So I could say something like, "Get the email," and then say, "Thank you," when it finished without having to say "Computer" a second time to get its attention. The "Thank you" was attached to a text file that was set to be spoken, which resulted in the computer saying, "You're welcome," each time I said that phrase. With an applescript as the target for a given spoken command, you can have it randomly select responses from a list of appropriate phrases for the given command.
__________________
There is no such thing as a stupid question. If you don't ask, you will never know. |
|
|
|
|
|
#11 |
|
Prospect
Join Date: Mar 2006
Posts: 10
|
I've been able to script a simple question/response dialog, however I am now stuck on 2 points, one is to apply the script continuously, and a second is while the script is running, the computer will not respond to other standard and custom commands. Can anyone help me out on getting this script to run as a constant command within the speakable items that does not interfere with existing commands? Here is the (simple) working script I've come up with so far:
PHP Code:
|
|
|
|
|
|
#12 |
|
Prospect
Join Date: Mar 2006
Posts: 10
|
However, I have had no success trying to figure out a way to script a response in recognition of the keyword such as the "whiit" would normally imply
|
|
|
|
|
|
#13 |
|
MVP
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
|
interesting.
On a hunch I just open the Speak-able items folder. Thinking Maybe you could put your script in there. The was a AS script already there. Named "Open Sherlock" I opened it and changed it to a different app. (Delicious Library) saved it and the ask the computer to "open Sherlock" it opened "Delicious Library" So I am assuming all you need to do is have a script like Code:
on run try say "Your [[emph+]]welcome." end try end run and place it in the Speak-able items folder. I've done this and it shows up in my commands window. But on my PB speak-able is a bit flakey, and will not respond to any bloody thing right now. |
|
|
|
|
|
#14 |
|
MVP
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
|
Yep it works......
|
|
|
|
|
|
#15 |
|
Triple-A Player
Join Date: Mar 2006
Location: South Blighty
Posts: 75
|
Does this (?useless) Mac OSX Speakable function work with any of you? (i'm not talking about your scripts...more the whole app itself).
I tried for half a day and could only get "What time is it?" to work ...surely it's quicker to look at my wrist?
__________________
PowerBook G4, 1.67Ghz, 1Gb RAM, 80Gb HD, 128Mb VRAM, Mac OS X.4.8 ... Extreme BaseStation 4thGen 20Gb iPod, Hdphn Remote, Senny PX100, Senny CX300, iSkin evo2, iPoDonut, iTrip 2nd Powerbook = G4, 550Mhz, 512Mb RAM, 20Gb HD, 16Mb VRAM, Mac OS X.4.8 |
|
|
|
|
|
#16 |
|
Prospect
Join Date: Mar 2006
Posts: 10
|
mark hunte, thank you so much! This is just what I've been looking for!
As for speakable items in general, I have a PB and it's touchy, and it definitely doesn't work with ANY other sounds in the room, so showing it off to friends makes me look like an ass, but then again, who talks to their computer AND has friends? |
|
|
|
![]() |
|
|