KutakMir KutakMir - 4 months ago 11
Bash Question

How to generate mp3 audiobook out of text files in mac

I have a folder with text files, each text file being a chapter of a book I want to turn into a mp3 audiobook. How do I do this on Mac?

Answer

You create two folders "input" and "output", input is a folder with txt files and output is a folder with mp3s. Now you just run this script:

#!/bin/bash


cd input
for i in * ; do

filename="${i%%.*}"
echo "$filename"
cat "$i" | say -o "../output/$filename.aiff" --progress
cd ../output
lame -m m "$filename.aiff" "$filename.mp3"
rm -f "$filename.aiff"
cd ../input

done

cd ..