A Computer with Personality.. Speakable Scripts

Greetings… I am new to the MacWorld so forgive me… (it rocks BTW)
So this is my first mac… a MacBook… I found the speakable items and I found applescript… woohoo
I want to create a computer with some personality… after much playing with i figured out this little script… nothing special but does part of the job i want…



set Speech_List to {"Your Welcome honey", "gazzuntite", "Yaa, Thats what I thought", "Whatever", "Just Doing my job.", "So, Can I get a raise?", "no no no, Thank [[emph +]]YOU", "Anything for you Daniel", "It's My pleasure", "I Live to but serve you master", "There is nothing i'd have rather done"}
set theNumber to random number from 1 to 11
say (item theNumber of Speech_List)


I named the script “Thank you” and made it speakable… woohoo works great
okay but it’s a bit messy… and it only answers to the exact “Thank you”… if I could change two things it would be

  1. I would like to make the phrases she is able to say, come from a text file… so I can enter them line by line in a cleaner way and edit them much easier…
  2. I see while looking for help a command called listen for… maybe with that someway I could make it so she responds to “thanks” and “good job” ect with the same script… but doesnt halt her other listening jobs… anyways if anyone has some ideas it would be great… i’d love to keep at this and eventually get a real personality going…

Later down the line if I can really figure this scripting out… it would be cool to make every response she gives me associated with some points… those points would reflect her mood… and the phrases I say to her have points on them too… so if i get her to angry she wont listen to me and starts getting nasty… so I’ll have to talk sweet to her…
I KNOW its possible to do with applescript… I’v done things like this (well… not really,… but kinda) with MUDs… anyways i’m done…
any ideas?
-Daniel

Using Apple’s speach recognition for semi-heuristic feedback moods? For someone just getting started, you’re diving into the deep end. :wink:

I would love to see how your project progresses, because I have been tinkering on and off with X-10 control of my condo using Xtension, which is driven by AppleScript. I can turn on a few lights in the house by voice and by X-10 touch panels, have some scripts with if-then logic, some basic Star Trek-style canned-style (says the same thing every time) acknowledgements and feedback.

Not pursuing it as serious as I would like, and haven’t figured out a way to make it “listen” in multiple places aside from near the Mac.

I’ll be watching this thread, sounds cool, and even possible, but the logic might get complicated.

Hi Daniel,

You could read from a text file and ‘say’ the paragraphs. Or get the paragraphsj in a list.

set t to “Great!
good
so so”
repeat with i from 1 to 3
say paragraph i of t
end repeat

or:

set t to “Great!
good
so so”
set p to paragraphs of t
repeat with i from 1 to 3
say (item i of p)
end repeat

Here the variable t has the the text value, but you could read from file.

set f to choose file
set t to read f
set p to paragraphs of t
set c to count p
repeat with i from 1 to c
set this_response to item i of p
say this_response
end repeat

The ‘listen for’ command is from the “SpeechRecognitionServer”. It’s a little flakey because it errors with timeouts. As you probably saw from your searches, you can use error handlers to catch the errors. I posted a lot of examples on using SpeechRecognitionServer and not have it timeout.

Lastly, you can change the voices of the replies with tags. I’m looking for the link.

Edited:
here’s the link for the embedded tags:

http://developer.apple.com/documentation/mac/sound/Sound-200.html#MARKER-9-221

Here’s the main page to Speech Manager info:
http://developer.apple.com/documentation/mac/sound/Sound-193.html#HEADING193-0

gl,

Woohoo Kel that was awsome… your post was right on the mark… now i’m not savy enough to understand exactly how ya ment it… but i got it to work for me using your script like thi.


set thePath to (the path to preferences) as string
get info for alias (thePath & "exam_speech.applescript")
set theFile to alias (thePath & "exam_speech.applescript")

set f to theFile
set t to read f
set p to paragraphs of t
set c to count p
set theNumber to random number from 1 to c
say (item theNumber of p)

That works just like i want it to.
okay… now i’m off to try and tackle the links your sent bout listen for… wish me luck
you kick ass BTW

-Daniel
All you base are belong to us

Okay, had a slight brain shower… not really a storm…
what if… I could make a governing script/application… the scripts job is to hold 4 variables, 3 of them constants being: Happy, Neutral, Upset… fourth variable being Current_Mood
using the script above… add in a check on the variable Current_Mood to see where is falls closer to of the other 3 variables… That in return tells the speakablescript what file to read from, the happy, neutral, or upset file… also whatever speakable item you choose will have it’s own modifier to effect “Current_Mood”… this will give real personality… as if the check comes back upset… maybe part of the script will not let her open the application or perform the task you want…
so… Any ideas on where to go next to figure this out? I looked into the “listen for” command… i decided against it as it will keep the script running… if this goes anywhere in depth, well… the multitude of open scripts will drag the computer down… the way around it is to keep the activation phrases simple and have a duplicate in the scriptable items folder such as “thank you” has a duplicate “thanks”… …
okay coming along nicely i’d say for a day in…
-DocRose
All your base are belong to us