9:54 am

Save Text As Audio

You can have your Mac speak text to you and also have it save that audio as a file that you can listen to later or even on your iPhone after syncing the file via iTunes. Learn how to take a text file and convert it to a spoken word audio file using the Terminal.

Video Transcript (Click to Expand)
So you probably already know you can have your Mac speak text you. It could be as simple as selecting text, Control clicking on it and going to Speech and start speaking. But you can also save this speech as an audio file. You can do this several different ways. There's a way to do it through Automator but it's even easier to do it using the Terminal.

So let's launch Terminal using Spotlight, Command Space Terminal and return. It's going to bring up the Terminal window. Now it's very easy to get the Terminal to talk to you. All you need to do is use the Say command. So you would use say, Say Hello and you get the default voice saying whatever text it is you've typed after the word Say.

Now you can customize the voice by going to System Preferences and then go to Accessibility, Speech, and here's the system voice and that's what voice it was using. Also note what other voices are present. So, for instance, instead of Alex we could have used Victoria. You can tell the Terminal to do that. So I could do Say and then dash V which means voice, Victoria, Hello. And it's Victoria's voice instead of Alex's voice.

Now I don't want to type out the entire bit of text that I want it to speak. I want it to read from a file like say that file we were just looking at or it could be something much longer than that. The way to do that, what you can do Say and I can do dash f and give it a file name. Now it's got to be the full path to the file so I could go and look at this file, do Command i and see that it's Macintosh HD users macmost desktop and then the name of the file.

Or an easier way to do that is drag and drop. If I have the prompt in terminal right there, I drag the file there, it will put the entire path there or at least the path that it needs. Then I hit Return and it will read the text of that file.

But how do we get this to a file in AudioFile instead of listening to it right there on the spot. Well, the way to do that is to use the O Command. So we're going to use dash O for output and give it a path to a file.

So let's create a file on the desktop here. I'm going to copy the path and everything except extension and I can just leave it with no extension but I'm going to use .aiff because that is the file format that it's going to use. So when I hit this it's going to do it but I need to give it some text. So let's just do hello here. You can see it created this aiff file and now when I play it I should get the word hello spoken by Alex.

So let's bring this all together. I'm going to delete this file that I created here and I'm going to have it say, using Victoria's voice, reading the file I'm going to drag and drop here, outputting to the file. I'm actually going to drag and drop again. But now I'm going to backspace and change .txt to .aiff.

So it's going to use Victoria's voice, it's going to take the input from this file and it's going to do output to this file here, got one too many f's. You can see it created it almost instantly. So it didn't actually have to read it in real time into the file. Now when I hit play on this audiofile I'll hear the whole thing.

Now this could've been a much longer file and I could be using it now drag and dropping it into iTunes, loading it onto my iPhone, sending it to somebody, listening to it later by putting it onto iCloud Drive. All sorts of different useful things for actually taking a long bit of text and having it transferred into an AudioFile so you can listen to it rather than read it.

Comments: 11 Responses to “Save Text As Audio”

    12/23/16 @ 10:32 am

    I don’t know how you find all this stuff out but that is awesome! please keep up the ‘terminal’ videos. I love it!

    12/29/16 @ 1:18 pm

    Hi Gary, great video. In saving to iPhone, would you then be able to add to voice memos?

    12/29/16 @ 2:34 pm

    Robert: No. Voice memos is all about recording your voice. You can put these audio files on your iPhone a number of other ways: iTunes sync, iCloud Music Library, iCloud Drive, lots of third-party apps, etc.

    12/29/16 @ 3:24 pm

    This is great. Can you go the “other way”? That is, take an audio file and have terminal create a text file?

    12/29/16 @ 3:44 pm

    Troy: Not really. The best way is to actually hire someone to transcribe the audio. That’s what people like me do (to create the transcripts for the videos here). There are apps that you can buy that try to do it via the computer, but they only work in ideal situations and even then need a human to review them and make corrections.

    Vaman Kale
    12/31/16 @ 3:40 am

    That was fantastic!! Many thanks. That’s why I always eagerly open your mail when it comes.

    1/5/17 @ 2:18 pm

    Gary, that was really neat about creating audio files. Now since I “think” the Mac can be language specific; is it possible to scan in, text in another language, say Spanish, and have the audio file read it back correctly? Thank you, and I really enjoy your weekly posts. pat

    1/5/17 @ 3:05 pm

    Pat: If you go into System Preferences, Accessibility, Speech you can choose “Customize” under the voice selection and pick voices in a large variety of languages, including Spanish. So I would start my switching to a Spanish voice first, then I would think it would read Spanish text very well.

    Mr. Luigi
    1/7/17 @ 2:06 pm

    Hi Gary, This was really awesome. Students with learning differences such that they need audio versions of written material could find this very helpful. Not all written learning resources come in audio versions and this gives students and their teachers an option to create them. Bravo to you!

    Eric Therrien
    1/14/17 @ 4:17 pm

    Gary good day,
    I did try to change a text to .aiff file but Terminal return an error.
    iMac-de-Famille:~ familletherrien$ say -v Chantal -f /Users/familletherrien/Desktop/LeTueuraGages.txt -o /Users/familletherrien/Desktop/LeTueuraGages
    Input text is not UTF-8 encoded
    That voice is in french!

    1/14/17 @ 6:12 pm

    Eric: Sounds like that text file may have the wrong encoding to work with the “say” command.

Leave a New Comment Related to "Save Text As Audio"


0/500 (500 character limit -- please state your comment succinctly and do not try to get around this limit by posting two comments)