Tutsplus and I were to make an Applescript tutorial. Unfortunately for Mr. Winters, I'm not really going to help him out anymore. So here is a fun little tutorial to make an script that narrates whatever you type into it and gives you an option of saving it as an MP3 file.
Here's the script, with the vaguely useful comments explaining every line.
Here's the script, with the vaguely useful comments explaining every line.
display dialog "Welcome to ReadAloud" buttons {"Next", "Cancel"} default button 1 -- Welcome dialog
repeat -- Repeat Statement 1
display dialog "Enter text to be read aloud" default answer "" buttons {"Next", "Canel"} default button 1 -- Taking input from user
set textInput to text returned of result -- Assigning input to variable 'textInput'
set voiceChoice to choose from list {"Vicki", "Kathy", "Victoria", "Alex", "Bruce", "Fred"} with prompt "Select a voice" -- Creates a list and displays a message telling the user to choose a voice to read out the text input
say textInput using voiceChoice -- The input is narrated using the selected voice
tell application "System Events" -- Ordering System Events
display dialog "Do you want to save this as an audio clip?" buttons {"Yes", "No"} default button 1 -- Displaying dialog to ask user about saving the audio clip
if the button returned of the result is "Yes" then
set clipName to "Voice Narration by " & voiceChoice & ".mp3" -- Defining name of file
set saveLoc to ((path to desktop as text) & clipName) -- Defining location of file
say textInput using voiceChoice saving to saveLoc -- Writing data to save file
end if
end tell
display dialog "Do you want to do it again?" buttons {"Yes", "No"} default button 2
if button returned of result is "No" then exit repeat -- Exiting repeat loop
end repeat -- Repeat Statement 2
Download the executable script here.
It works. I think.