On Oct 30, 2014, at 7:17 AM, Rob Lewis wrote: I normally keep 2 user accounts logged in on my server: a “foreground” one for doing work, and a “background” one that runs all my home automation stuff.
It appears that the “say” verb doesn’t produce any output when run from an account that’s in the background. Is there any way around this?
One idea is to have a “helper” application running in the foreground account, and in the background account run something like this:
(where the SpeechHelper app would have an “articulate” handler that just called the “say” verb)
Will this work? Is there an easier way?
Hi Rob,
Here's what I'd do to accomplish your task.
1. Create a folder accessible to both users, perhaps "/Users/Shared/SayMe/" or whatever.
2. Have the background process write the text to be spoken in timestamped text files in the "SayMe" folder. Timestamping (i.e. – "2014-10-03_16.49.35.txt") will allow them to be retrieved and spoken in order.
3. The foreground process would poll for text files, speak them, then delete them. Alternatively, you could archive the files or log the spoken text.
Below is some quick-and-dirty code you can use as a starting point for the foreground process, which would need to be saved as a stay-open script application.
HTH, Stan C.
on run idle end run
on idle set sayFolder to "/Users/Shared/SayMe/" try -- look for files to speak set filesToSay to paragraphs of (do shell script "ls " & sayFolder & "*.txt") on error errText number errNum if errText contains "No such file or directory" then set filesToSay to {} else -- unknown error, so throw it error errText number errNum end if end try -- speak and delete each file repeat with i from 1 to (count filesToSay) do shell script "say <" & item i of filesToSay do shell script "rm " & item i of filesToSay end repeat return 5 -- seconds until next poll end idle
|