blocks_image

Focus '0 siX - F.O.X.

<<== Back

The first A.I. - Artificial Intelligence of Fox


Download: all files of [Project F.O.X.] so far.
(And U can use it at your home as well, not only in a car called Focus '06 :-D )


The Speech Recognition Program(s)

When i tried out Mac Speech Dictate the first time for speech recognition, I realized that I could open any progam that was in my (default) application folder, just by saying "open" and it's program name.
By saying "open iTunes" Mac Speech Dictate (later on MSD) opened the music program.
MSD puts automatically "open" infront of each (speakable) application name, but under the Tools options you can remove "open" from each command which is very useful for building up conversations.

The Talk

So, what about conversations? How to talk to the computer?
On one side MSD can open programs, on the other side you need to reach the "say" command that is built in to the Mac Os X.
If you open the terminal and type "say hello world", the default voice of the Mac Os activates and says "hello world".
Now you connect "program" and "say-command" by using Applescript :)
For example:
Open the Script editor and just put in
>>
say "hello world"
<<
and save it as hello.app in your Mac Os X Application Folder.

* By using the own speech recognition of Mac Os X (click on Systempreferences pane -> speech and activate), mark the hello.app file, press ESC and say "make this speakable".
Then you just say "hello" or "open hello".

See also: => Using Mac Os X own/built in speech recognition

* By using MSD you have to restart MSD and just say "open hello".

Now the computer says "hello world". Woohooooo!

You see, the file name of this Applescript is your phrase/question/request to the computer and the content of this script is the answer.

The Right Mood - random answers

Another example, but this time the computer gets a bit smarter, because it choose (randomly) between different answers:
Open the Script editor and just put in
>>
set randomNumber to (random number from 1 to 4)
if randomNumber is 1 then
say "dude! do i look like your butler? open the windows yourself."

else if randomNumber is 2 then
say "dude, are you kidding me? i am sitting in the glovecompartment and that is you, who's closer to the damn buttons!"

else if randomNumber is 3 then
say "dude, i am not opening stuff that comes from microsoft!"
else
say "i am sorry, my central processor unit is not wired to the windows, therefore i can not open."
end if

<<

Save it as "the windows.app" in your Mac Os X Application Folder. Now make the file speakable and/or restart MSD and say "open the windows".

Now you can say this all night long and the computer gives you always randomly one of the 4 answers.

Make it remember

It would be nice if the computer could remember what you just said and if possible block for an answer if you request something twice or more ;-)
Easy... create 2 text files on your desktop (i call them "fox_mem-human1.txt" and "fox_mem-cpu1.txt").
Then, read in the 2 text files in every script and check if neccesary before using the say command.
My current A.I. script would look like this:
[the windows.app]

>>>
-- change here or put in here "nameOfThisApp" (without '.app')
set this_app to "the windows"
--****************************************
--read memory file (what did the human say?)
set mem_human_file to (path to desktop as string) & "fox_mem-human1.txt"
set mem_human_file_content to open for access file mem_human_file
set data_from_mem_human_file to read mem_human_file_content as string
close access mem_human_file_content
--****************************************

--****************************************
--read memory file (what did the computer say?)
set mem_cpu_file to (path to desktop as string) & "fox_mem-cpu1.txt"
set mem_cpu_file_content to open for access file mem_cpu_file
set data_from_mem_cpu_file to read mem_cpu_file_content as string
close access mem_cpu_file_content
--****************************************

--begin if content of file = Conclusion
if (data_from_mem_human_file = this_app) then

set randomNumber to (random number from 1 to 5)

if randomNumber is 1 then
say "well, you do remember that I said "
say data_from_mem_cpu_file
say ", right?"

else if randomNumber is 2 then
say "dude, you just said this a moment ago!"
say "and I answered this:"
say data_from_mem_cpu_file

else if randomNumber is 3 then
say "are you deaf? I just responded to your request."

else if randomNumber is 4 then
say "Why do I have to answer to your request again? well, i just said:"
say data_from_mem_cpu_file

else
say "Are you enjoying repeating yourself?"

end if



--if there is no 'memory', write to file what the human said/asked
else


set human_text to this_app
set mem_human_file to (path to desktop as string) & "fox_mem-human1.txt" as file specification
open for access mem_human_file with write permission
set eof of mem_human_file to 0
write human_text to mem_human_file
close access mem_human_file

--and

-- begin give out a random text (and put it into an own memory file)
set randomNumber to (random number from 1 to 3)
if randomNumber is 1 then
set cpu_text to "do i look like your butler? open the windows yourself."
set mem_cpu_file to (path to desktop as string) & "fox_mem-cpu1.txt" as file specification
open for access mem_cpu_file with write permission
set eof of mem_cpu_file to 0
write cpu_text to mem_cpu_file
close access mem_cpu_file
say cpu_text

else if randomNumber is 2 then
set cpu_text to "i am so not opening stuff that comes from microsoft!"
set mem_cpu_file to (path to desktop as string) & "fox_mem-cpu1.txt" as file specification
open for access mem_cpu_file with write permission
set eof of mem_cpu_file to 0
write cpu_text to mem_cpu_file
close access mem_cpu_file
say cpu_text

else
set cpu_text to "i am sorry, my central processor unit is not wired to the windows buttons, therefore i can not open."
set mem_cpu_file to (path to desktop as string) & "fox_mem-cpu1.txt" as file specification
open for access mem_cpu_file with write permission
set eof of mem_cpu_file to 0
write cpu_text to mem_cpu_file
close access mem_cpu_file
say cpu_text

end if
-- end give out a random text (and put it into an own memory file)

end if
<<<

[ NEXT PAGE ] - 2 Step Memory, Memory Status, Synonyms, asking time n date, triggering other actions by AI,...