Applescript: How to save text2speech and convert to mp3? I have this applescript in an automator service. it works.

I cannot however get it to save to my desired directory, or convert to mp3.

At the most basic, I would like to save to /Users/&lt;user&gt;/Music/Mandarin-text2speech.

Ideally, I would like filenames to increase incrementally, convert to mp3 and delete the aiff.

here is my basic script that works for now.

on run {input, parameters}
  repeat with thisText in input
      say thisText speaking rate 130 using "Mei-Jia" saving to file (((path to desktop) as string) &amp; "audio.aiff")
  end repeat
end run
The say command has been able to save in different formats for a while.  The supported formats can vary with the voice, but for Mei-Jia it will save to mp3 or mp4 directly, so you don't need to do any converting or deleting.

EDIT:
Looks like I was mistaken about the encoding - there isn't an mp3, but you can use the say shell script to set other encodings such as mp4:

on run {input, parameters}
    set saveFolder to (((path to music folder) as text) &amp; "Mandarin-text2speech:")
    repeat with thisText in input
        set fileName to getUniqueName for "audio.mp4" from saveFolder
        set output to quoted form of POSIX path of (saveFolder &amp; fileName)
        do shell script "say -v 'Mei-Jia' -r 130 -o " &amp; output &amp; " --file-format=mp4f " &amp; quoted form of thisText

    end repeat
end run

to getUniqueName for someName from someFolder -- add a numerical suffix as needed to get a unique name
    set {divider, counter} to {"_", 0} -- the dividing text and starting suffix number
    set leadingZeros to 2 -- maximum leading zeros
    set here to -(offset of "." in ((reverse of text items of someName) as text)) - 1 -- split extension at last period
    set theName to text 1 thru here of someName
    if here is -1 then -- no extension
        set theExtension to ""
    else
        set theExtension to text (here + 1) thru -1 of someName
    end if

    if counter &lt; 1 then -- always start with a suffix
        set counter to 1
        if leadingZeros &gt; 0 then set counter to text -(leadingZeros + 1) thru -1 of ("000000" &amp; counter)
        set newName to theName &amp; divider &amp; counter &amp; theExtension
    else -- only add suffix as needed
        set counter to counter - 1 -- adjust for while loop
        set newName to theName &amp; theExtension
    end if
    tell application "System Events" to tell (get name of items of folder (someFolder as text) whose visible is true)
        repeat while it contains newName
            set counter to counter + 1
            if leadingZeros &gt; 0 then set counter to text -(leadingZeros + 1) thru -1 of ("000000" &amp; counter)
            set newName to theName &amp; divider &amp; counter &amp; theExtension
        end repeat
    end tell

    return newName
end getUniqueName