Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

metalmaniac

macrumors newbie
Original poster
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
 
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.
 
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
 
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
 
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


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.

:)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.