Personal Assistant/ Iron Man

Hey guys (and gals)!!

Okay, so you’ll laugh at me, but I just saw Iron Man for the first time last night, and thought it was so cool how his room wakes him up, tells him the weather and the stats for the day. I leaned over to the girl sitting next to me and said, “My room does that too!” (as a joke) and we both laughed. Then I said, “no! seriously!”

From then, I decided I was going to program a “mock” Personal Assistant, and am having some struggles with what I want to accomplish.

So far, I have some scripting along the lines of having my computer give a morning greeting, then it reminds me to do some stuff that I should do every day. (Yay for prayers! :wink: ) I even got it to open my e-mail and Pandora.com so that it’ll play some nice wake-up music for me.

Here’s what I want to program, and if you could help me (or even let me know if it’s possible) that’d be great! I want to have several “morning greetings” that my computer would be able to “choose” from in the morning, so that I don’t hear the same thing every morning, nor have to re-write the script every night. Would it be possible to set up some sort of “randomizer”? Also whats the possibility of having my computer check some type of feed and also tell me the weather forecast for the day?

I know its a bit advanced, maybe even not possible with my system, but any help is appreciated!

Thanks again guys!
Brayd

Model: iBook G3 600 MHz, 640 MB RAM
Browser: Whatever
Operating System: Mac OS X (10.3.9)

Hi saxophonegeek,

Here is some code that shows you two simple ways to implement a randomizer for your morning greetings:


-- simple randomizer
set greetings to {"Hi, it's time to wake up!", "Get up, man!", "Snoozle doozle!", "Tooooo late!"}
set greeting to some item of greetings
say greeting

-- more advanced randomizer
property oldrandnum : missing value
set greetings to {"Hi, it's time to wake up!", "Get up, man!", "Snoozle doozle!", "Tooooo late!"}
set countgreetings to length of greetings
repeat
	set randnum to random number from 1 to countgreetings
	if oldrandnum is missing value or (randnum ≠ oldrandnum) or (countgreetings = 1) then
		set oldrandnum to randnum
		exit repeat
	end if
end repeat
set greeting to item randnum of greetings
say greeting

You could download, read and parse a feed with the curl command:


set command to "curl " & quoted form of "http://images.apple.com/main/rss/hotnews/hotnews.rss"
set feedcontent to paragraphs of (do shell script command)
repeat with feedline in feedcontent
	if feedline begins with "<title>" then
		set newstitle to (characters 8 through -9 of feedline) as Unicode text
		display dialog newstitle
	end if
end repeat

Happy scripting! :smiley:

Awesome! Thank you SO MUCH! Now theres one more question, is there anyways I can run this script (as a program on startup) without having it to ask me whether I want to run or quite the script . . . the idea is for it to wake me up in the morning . . . .

Thanks AGAIN!!
:slight_smile:

Brayden

If you see a splash screen asking you whether you want to run or quit the script, the you saved the AppleScript with the option «Startup Screen» selected. Just save your AppleScript without the «Startup Screen» option to avoid this splash screen.

Okay, I’m loving this randomizer script, but had just a few more questions. (sorry) But I really do appreciate you helping me, and teaching me some cool things about some basic programming. First question: How easy is it to adapt that last “curl” reader, to read a “Weather RSS Feed?” For some reason, I’d copy in the RSS URL in place of the Apple one, and it wouldn’t work. Question two, I got that splash screen to disappear, but now when my computer starts up, it displays an error message, code -10818. I have a feeling it has to do with the speech, because the script does the rest of what I want. How can I fix that error, to get the talking on startup?

THANK YOU AGAIN, so much!

Brayden

*bump * :slight_smile: I’m mainly concerned with that error . . . any ideas?

Why not build the real deal with Xtension, some X-10 goodies, and AppleScript? :wink:

Before I got married I was working on such a project. Got as far as having the shower lights turn-on, the heat lamp warm the bathroom up about 10 minutes before I got up, tell me the status of all X-10 devices via voice recognition, and special “leaving the house” and “I’m back” setups to switch off any lights I forgot.

Even made it polite…it would respond properly to “thank you” comments. :wink:

All with an old OS 9 box I was already using for my firewall (IPNR)…

GEEK ALERT! :lol:

HAhahahaha! :slight_smile: I would . . . I fact is, I am but a poor college student. How much does something like Xtension cost?

Xtensiuon link. :slight_smile:

Or using the techniques outlined in this tutorial you could build your own weather forcast.

I’m trying to do the same thing! I’m using Insteon home controllers and Indigo to run the devices, and I’ve started with some simple speakable items applescripts to turn a few lamps on and off. I’m still a novice, but I have Jarvis (I bought the Cepstral Lawrence voice for the British accent like in Iron Man!) saying some randomized hellos and You’re welcomes so far like this:

It’s named GoodMorning and placed in the Speakable Items folder. I took the space out because it wasn’t recognizing “Good Morning” as I run the two words together while speaking.


set theOptions to {"Good Morning sir.", "welcome back sir", "indeed it is sir.", "What's on the schedule today, sir?."}
set theChoice to some item of theOptions
say theChoice displaying theChoice with waiting until completion

I’ll look at that tutorial to see if I can figure out how to pull the data I want. In response to “Status Report” or “Good Morning” or something, I would like the computer to say something productive like: "Good (morning/afternoon/evening), it is (current time) and the current temperature is (temp) with (current conditions). The surf report for (Pismo Beach) is (x high waves) with winds at (x mph) from (direction). On the schedule today is (calendar agenda).

Or something like that. I think I have a lot of reading to do. :wink: Thanks for the help!

I love my Mac but how come I’m the only one that would rather have Gwenyth Paltrow wake me up in the morning? :smiley: (I think I need to subclass NSHottie.)