• 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: Rob Lewis <email@hidden>
  • Date: Wed, 05 Nov 2014 12:00:01 -0800

Great idea, Stan. Thank you! 

Do you think there’s any reason one couldn’t use a Folder Action Script to do basically the same thing? 

Also, oddly, I’ve noted that SOMETIMES speaking from the background account works. Bug or feature? Who knows? 

What I’m using right now in the background script is this: 
do shell script “say \”some text to speak\” &>/dev/null &” 

That stuff at the end is some voodoo I found somewhere that’s supposed to let the speech run without holding up script execution. But just to make sure, I wrapped it in an “ignoring application responses” block (belt & suspenders, for sure!) 

On Nov 3, 2014, at 5:05 PM, email@hidden wrote:

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

  • Follow-Ups:
    • Re: Use "say" from a background user account?
      • From: Stan Cleveland <email@hidden>
    • Re: Use "say" from a background user account?
      • From: Alex Zavatone <email@hidden>
  • Prev by Date: Re: Smile Toolbar Buttons
  • Next by Date: Re: Use "say" from a background user account?
  • 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