PDA

View Full Version : Text to Speech




spotlite
Feb 5, 2008, 12:03 PM
Hello everyone,

I'd like to develop a small Console App that when passed in a String, will output via speakers or return/create a .wav file of said string. Very similar to what Mac OS does with its built-in Text to Speech feature. Are there any built in libraries or frameworks that support this. Thank you for your help!



kpua
Feb 5, 2008, 12:17 PM
It essentially already exists. Try the "say" command.

If you still want to fiddle with it, look at the SpeechSynthesis framework.

kainjow
Feb 5, 2008, 12:27 PM
Apple has docs and sample code (http://developer.apple.com/documentation/Cocoa/Conceptual/Speech/Articles/SynthesizeSpeech.html) for doing this.

asciimov
Feb 5, 2008, 02:28 PM
in terminal take a look at the manual page for say

ie... in the terminal type man say

you will find that the flag for output is -o

so if you typed in terminal say -o wave.aiff "Hello, I am talking."
It will generate an aiff file with the spoken text in the directory that you run the command from (pwd will give you the current directory in terminal)

toddburch
Feb 5, 2008, 03:01 PM
Cool. That worked great. However, when I double clicked it, it opens iTunes, played it, and added it to my library. How can I play the saved aiff without iTunes involvement?

Thanks, Todd

asciimov
Feb 5, 2008, 03:12 PM
use say without the -o flag, and say will just output sound
ie... say "hello how are you"

toddburch
Feb 5, 2008, 03:13 PM
use say without the -o flag, and say will just output sound
ie... say "hello how are you"

Right - I get that. I did that. The question now is how can I play the -o generated file without iTunes?

JNB
Feb 5, 2008, 03:19 PM
BTS, the quotes aren't needed.

toddburch
Feb 5, 2008, 03:30 PM
A right-click allows me to open it with Quick Time. I was wondering if there was a command that would play it.

kpua
Feb 5, 2008, 03:38 PM
open -a "Quicktime Player" <file> to open it from the command line in Quicktime.

kainjow
Feb 5, 2008, 04:11 PM
A right-click allows me to open it with Quick Time. I was wondering if there was a command that would play it.

AFAIK there is no built-in command to play audio files, but there is an open source app called qtplay that you can download that does this.

don't do it
Apr 18, 2008, 03:11 PM
Here is a applescript that will do what you want it to it will first ask for a voice to use then what you want changed to speech then where you want to save it. Also keep the .aiff part there otherwise it will not work and you can change it to an .mp3 file in iTunes just make sure it opens in something other than iTunes. Also it might have some bugs so if anyone would be so kind as to fix them and tell me about them that would be great.:D

CaptainZap
Apr 18, 2008, 04:16 PM
If you want a simple command line audio player, look in the TextMate resources, you should find one called play. It works nicely and can even play the audio of videos.

It is in Contents/SharedSupport/Support/bin

credit1
Apr 20, 2008, 11:23 AM
or it is just for mac computers?