Hello MacScripters,
First let me say how impressed I am with this forum - I am learning AppleScript so quickly by reading this forum, it’s well just amazing. For my first post I will tell you what I’ve been up to lately, which is combining the scripting language of the online virtual world called Second Life with AppleScript, specifically with the goal in mind of helping People with Disabilities (PWDs).
I have long dreamed of fashioning some type of dynamic world based on networked computers that combined all sorts of fun stuff like chat, virtual reality, music listening and creation, human interface devices, video, collaboration, 3D design, and whatever else tickles your fancy into one dynamic interoperable environment. I know, you are saying “yeah, they call that AppleScript”, haha! Well being a scripter from back in the 1980’s until today, I have remained blissfully ignorant of the incredible power of AppleScript for doing just what I wanted. That is, until a few days ago.
That’s when I realized I could use http function calls in the scripting language of Second Life (Linden Scripting Languat, or LSL) to link scripted 3D virtual reality objects to my Mac’s applications via AppleScript! To demonstrate the concept I wrote a quick little application that reads the local chat that users and objects type into and converts that into audible speech on the local Mac as well as in the Second Life environment. It took a few hours to get the first one running, mostly because I had to learn enough AppleScript to do the job in that time.
Well, long story short I showed this text to speech program to some folks in a Second Life group called Virtual Ability, run by the real life non-profit organization Virtual Ability Inc. and they just loved it! Although text to speech had been done before, this was a server-less implementation which required no cost other than what was already spent by the user and they liked that aspect of it. Further, I explained to them that a wide variety of similar scripts could be written to facilitate disabled people, especially severely disabled people in living fuller lives through the magic of virtual reality. Closing the story, now we are holding a meeting tomorrow (Wednesday 11-21-2012) to discuss this with scripters, PWDs, and anyone else interested in such things.
So I thought I would introduce myself and share the code that sparked all the imagination about how to help the disabled by combining virtual reality via Second Life with AppleScript. I call it AppleScript + LSL. Below please find the AppleScirpt client code and the LSL server code that work together across an HTTP connection (and via email) to accomplish this particular form of text to speech. Please pardon my scripting ability as I have just learned barely enough AppleScript to do this job, oh well! Here we go:
-- This Software is Protected by the GNU General Public License
-- See http://www.gnu.org/licenses/gpl.html for details
-- A copy of the GNU GPL is included with this Distribution
--
-- by emSynth
--
tell application "Mail"
check for new mail
set checker to (messages of inbox whose read status is false)
set neworder to number of items in checker
if neworder > 0 then
repeat with i from 1 to number of items in checker
set msg to item i of checker
if msg's subject contains "HTTP Chat Monitor URL" then
set webLink to last paragraph of msg's content
set read status of msg to true
end if
end repeat
end if
end tell
set webLink to middle paragraph of webLink
set curlFolderText to path to desktop as text
set curlFolder to POSIX path of curlFolderText
set curlFile to "curlMessage.txt"
set curlCommand to "curl " & webLink & " -o " & curlFolder & curlFile
if webLink is not "" then
set capNotFound to false
repeat until capNotFound is true
do shell script curlCommand
set fileName to curlFolder & curlFile
set fileDescriptor to open for access fileName
set len to get eof fileDescriptor
set fileText to read fileDescriptor from 1 until "!"
close access fileDescriptor
set rmCommand to "rm " & curlFolder & curlFile
do shell script rmCommand
if fileText contains " not found" then
set capNotFound to true
else
say fileText
end if
end repeat
end if
So that’s the code, much of it copy/pasted from a few web sources and the rest of it hodgepodged together by myself. I dont’ really “GET” the HTTP layer all that intuitively (pun intended), but I am catching on slowly with each HTTP script set that I create. I’d like to finish up this post by reiterating that this text to speech script set is not the thing that is amazing me so much - it’s all the myriad of other incredible things that can be accomplished with the combination of AppleScript + LSL.
Some examples I’ll quickly mention are control of iTunes from a 3DVR jukebox in an SL club, voice control of moving the avatar and other functions for PWDs who lack the ability to do so, in-world virtual reality versions of Mac applications with or without multi-user collaboration features, integration of music creation tools such as digital audio workstations and music programming languages into the Second Life virtual world, and the list goes on and on ad infinitum.
I’ll finish up by thanking you as reader or especially as poster and scripter of code here at MacScripter for your contributions to my rapid learning experience that is fueling all of this excitement. I am having a great time and helping others which are both very satisfying. So keep on truckin’, MacScripters!
emSynth