Text to Speech

Discussion in 'Mac Programming' started by spotlite, Feb 5, 2008.

  1. macrumors newbie

    Joined:
    Jan 28, 2008
    #1
    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!
     
  2. macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    It essentially already exists. Try the "say" command.

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

    kainjow

    Joined:
    Jun 15, 2000
  4. macrumors newbie

    Joined:
    Jan 31, 2008
    #4
    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)
     
  5. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #5
    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
     
  6. macrumors newbie

    Joined:
    Jan 31, 2008
    #6
    use say without the -o flag, and say will just output sound
    ie... say "hello how are you"
     
  7. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #7
    Right - I get that. I did that. The question now is how can I play the -o generated file without iTunes?
     
  8. JNB
    macrumors 604

    JNB

    Joined:
    Oct 7, 2004
    Location:
    In a Hell predominately of my own making
  9. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #9
    A right-click allows me to open it with Quick Time. I was wondering if there was a command that would play it.
     
  10. macrumors 6502

    Joined:
    Jul 25, 2006
    #10
    open -a "Quicktime Player" <file> to open it from the command line in Quicktime.
     
  11. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #11
    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.
     
  12. macrumors regular

    Joined:
    Apr 18, 2008
    Location:
    somewhere on the Earth
    #12
    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
     

    Attached Files:

  13. macrumors regular

    Joined:
    Jan 17, 2007
    #13
    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
     
  14. macrumors newbie

    Joined:
    Apr 1, 2008
    #14
    Is this supported on iphone os?

    or it is just for mac computers?
     

Share This Page