• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Use "say" from a background user account?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use "say" from a background user account?


  • Subject: Re: Use "say" from a background user account?
  • From: Stan Cleveland <email@hidden>
  • Date: Mon, 03 Nov 2014 17:05:46 -0800

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: 
tell application “SpeechHelper” of machine “eppc://ForegroundUsername:ForegroundPassword@<IP address of the machine>” to articulate “String I want to speak”

(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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Indesign custom dialogs 2. try
  • Next by Date: Re: Indesign custom dialogs 2. try
  • Previous by thread: Re: Use "say" from a background user account?
  • Next by thread: Re: Use "say" from a background user account?
  • Index(es):
    • Date
    • Thread