Applescript for say to ask for input then record to audio file help!!!

Discussion in 'Mac Programming' started by metalmaniac, Aug 19, 2009.

  1. metalmaniac macrumors newbie

    metalmaniac

    #1
    Hey, ive made a probably incorrect bash script as i am a bash newbie

    -----------
    #! /bin/bash

    echo -n "Filename?"

    read -e FILE
    echo -n "Say?"
    read -e WORDS

    say -v Victoria -o "~/Desktop/$FILE.aiff" "$WORDS"

    echo File saved to Desktop as $FILE.aiff
    ---------------

    Now the idea as I see it, as I understand from glaringly confusing help sites on the interweb is that the script -
    1) ask the filename you want,
    2) assigns that to the variable FILE
    3)then asks what you would like Vicky to say
    4 ) Assigns that to the variable WORDS
    5) then types into the terminal the command id like,

    I need to use this for some production work im doing and it is ruddy annoying having to do all the commands over and over for each line i need to make.

    so is this anywhere near correct, and also how the hell do i make it an app i can just click on in finder pops up does it business then dissappears?


    Any help would be greatly appreciated. And please, dont say use the search, i have tried and the more i read up the more confused i get about bash on mac.


    Thanks
     
  2. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    You need to make a script executable (chmod u/g/o +x) to launch it, but doing this with AppleScript may be your best bet here. That way you can have it pop up a nice system file chooser or make it into a droplet. You can call shell commands from AppleScript too so you could mix and match to get what you need, in other words it could open more possibilities than just using the command line alone, but won't preclude you from using those either.
     
  3. metalmaniac thread starter macrumors newbie

    metalmaniac

    #3
    Thanks!!

    Ok i am using applescript instead, and its sorta working.

    ------------------
    set input to ""
    set voice to ""
    set outputfile to ""

    display dialog "Enter text to be spoke:" default answer input
    set input to text returned of result

    choose from list {"Bruce", "Fred", "Junior", "Ralph", "Agnes", "Kathy", "Victoria", "Albert"} with prompt "Please select System Voice:" default items {"Victoria"}
    set voice to items of result

    choose file name with prompt "Where would you like to save your .aiff file?" default name "Audio.aiff"
    set outputfile to name of file

    say input using voice saving to file outputfile
    ------------

    ive realised the set outputfile to name of file is a wrong command, but how would i get the result of the choose filename command and assign that as the value of outputfile?



    thanks in advance
     
  4. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #4
    This should work:

    Code:
    set input to ""
    set voice to ""
    set outputfile to ""
    
    display dialog "Enter text to be spoke:" default answer input
    set input to text returned of result
    
    choose from list {"Bruce", "Fred", "Junior", "Ralph", "Agnes", "Kathy", "Victoria", "Albert"} with prompt "Please select System Voice:" default items {"Victoria"}
    set voice to items of result
    
    set outputfile to (choose file name with prompt "Where would you like to save your .aiff file?" default name "Audio.aiff")
    
    say input using voice saving to outputfile
    
    say input using voice
    Apple's documentation on the say command could be a bit more discursive, if I say so myself.

    The "choose file name" command provides a path and filename. All you need to do is say "saving to outputFile"

    Curiously, Applescript won't send the data to the speaker, so that's why there's a second "say" command.

    mt
     
  5. metalmaniac thread starter macrumors newbie

    metalmaniac

    #5

    You didn't have to say should work, it does work, brilliant thankyou, solved, i didnt need the second say command as it quicker to put it straight to file and import that to logic pro, but thankyou. Next up is how to integrate this to Logic, but i'll leave that for another day.

    :)
     

Share This Page