View unanswered posts | View active topics It is currently Wed May 22, 2013 10:59 am



Reply to topic  [ 3 posts ] 
 Spoken messages that vary in length 
Author Message

Joined: Jul 06, 2010
Posts: 498
Location: Petoskey, MI
Post Spoken messages that vary in length
Perhaps this has already been addressed, but I couldn't find it searching. I can imagine others would be looking for this sort of functionality as well.

Right now, I am using airfoil and switching the source to indigoserver to call out spoken messages. I have the action to go back to the previous source on a time delay... however, what if the messages vary in length to be spoken in 3 seconds and 30 seconds? I have to set my delay for 30 seconds to account for the longest message, while the short messages get a long awkward silence after them if I am playing any sort of music.

I realize I could just pause the music and use system audio out without bothering to switch the source, but having the source be specific, whether it is Pandora or itunes offers me some advantages that I'm not willing to throw out just to solve this particular issue.


Fri Oct 05, 2012 11:13 am
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6658
Location: Austin, Texas
Post Re: Spoken messages that vary in length
The indigo.server.speak command in the Python API will wait until the speech is finished before continuing the script - so if your actions are (or can be) scripts then you can use that.

_________________
Jay (Indigo Support)
Image


Fri Oct 05, 2012 3:13 pm
Profile WWW

Joined: Aug 09, 2010
Posts: 765
Location: CA
Post Re: Spoken messages that vary in length
I don't think there's any way of detecting how long a spoken message lasts when using IndigoServer as the source of spoken text. The only way I can think of to get this information would be to use the AppleScript (or command-line) "say" function to create an audio file containing the text to be spoken, then using the command-line "mdls" command to gather the file's metadata information and extract the playback duration from that. This, however, would require you to re-engineer all of your spoken messages. In any case, here's some AppleScript code that will generate the audio file and return the duration in seconds.

Code: Select all
tell application "Finder"
   -- Create the sound file with the spoken text.
   say "This is just a test." saving to "/Users/nsheldon/test.aif"
   -- Delay a bit to allow the system to populate the metadata for the new file.
   delay 0.7
   -- Get the metadata information on the file.
   set theResult to do shell script "mdls /Users/nsheldon/test.aif"
   -- Look through all the lines in the output.
   repeat with theText in the paragraphs of theResult
      -- Convert the line of data to text.
      set theText to text of theText
      -- Look for the file duration information.
      if theText starts with "kMDItemDurationSeconds" then
         -- Remove the parameter name from the information.
         set AppleScript's text item delimiters to "= "
         set theDuration to text item 2 of theText
         set AppleScript's text item delimiters to {""}
      end if
   end repeat
   -- Return the result as a number (instead of text).
   return theDuration as number
end tell

EDIT: I composed this before seeing Jay's response. I think the indigo.server.say option is a better way to go, but the above code may still be useful for you.


Fri Oct 05, 2012 3:29 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.