PDA

View Full Version : Applescript help-- speech commands




messhof
Feb 12, 2008, 11:20 AM
Hi,
I'm trying to convert a series of transcribed interviews to spoken text through applescript. So far I've been using:

say "this is what one person says" using "Ralph" saving to file (((path to desktop) as string) & "test.aiff")

But I'd like to use two different voices (eg. "Ralph" and "Fred") to differentiate the two speakers. This is very time consuming to do with the above script. What I'd like to have is a script that takes a text file like this:

Ralph: Where were you born?
Fred: Montana
Ralph: I see

And uses the strings "Ralph: " and "Fred: " to create speech files with the different voices as well as a number in the filename to show it's position in the conversation. I guess ideally it would just create one speech file with all the back and forth speech files compiled, but I have a feeling that isn't possible with applescript... although maybe it can do it through quicktime or audacity.

Any help is much appreciated!
-Mark



toddburch
Feb 12, 2008, 11:46 AM
A ruby (or other language) could be written to take the form you want and produce the form you need. I can help. Send it to me in the form you want to write (or post a URL where I can get it) and I'll make it look like the form you need. Sounds fun!

Todd

messhof
Feb 12, 2008, 12:35 PM
Well I think I'd need the script myself as I'd be doing this every week for a podcast, but my transcripts look just like the quote I posted--
Ralph: Where were you born?
Fred: Montana
Ralph: I see
And I think I would just use the Ralph and Frank mac speech voices. Maybe add the recognition for Vicki, Victoria, and the rest in case I have more speakers?

It would be so awesome if you can help!

toddburch
Feb 12, 2008, 12:45 PM
That's what I meant - I'll give you the script (well, I'll just post it here).

I'll set it up to work with any voice left of the colon. I can do this tonight.

Todd

messhof
Feb 12, 2008, 12:51 PM
Thanks so much.

toddburch
Feb 13, 2008, 12:32 AM
OK, here you go. There are two different versions of this ruby script.

The first one, called saydialog.rb, generates the applescript "dialog.scpt" and puts in on your desktop. You can then run dialog.scpt to generate the aiff files. They are numbered test1.aiff through testnn.aiff.

The second script, saydialog_and_play.rb, generates the same applescript as above, but then goes on to play the dialog (without actually creating the test1.aiff + files) for you to preview them.

To run either ruby script, stick them in a folder or on your desktop, then open Terminal and navigate to the folder. On the command line, enter:


$ ruby saydialog.rb input_file_name

or

$ ruby saydialog_and_play.rb input_file_name


where input_file_name is the name of the file with your dialog, like "dialog.txt" or some such name. If your dialog file is not in the same folder, then qualify it so Ruby can open it.

I've also attached the file I used to test this with called saytext.txt. To use it, you would type:

$ ruby saydialog.rb saytext.txt

assuming they were both in the same folder.

Todd

p.s. I had to add a .txt extension to both scripts so I could upload them. Rename them by removing the .txt extension.

jeremy.king
Feb 13, 2008, 01:44 PM
Here's a sweet app that will combine all those AIFF files for you.

http://rogueamoeba.com/fission/

messhof
Feb 13, 2008, 11:01 PM
This is great! What a huge time saver. Thank you!