I have 300 English text files that I want to make into mp3 files to listen to as and when.
Is there a method, that I could use so that my Mac will batch text to speech the files to mp3 using a rotating voice from the free voices available on Mac OSX?
Best Answer
You can use a shell command like this:
Random English voice:
IFS=$'\n';a=($(say -v\?|sed -E $'s/ {2,}/\t/'|awk -F$'\t' '$2~/^en_/{print $1}'));for f in *.txt;do say -v "${a[$((RANDOM%${#a[@]}))]}" -f "$f" -o "${f%txt}aif";done
Random voice from a list:
IFS=, read -a a<<<'Daniel,Fiona,Moira,Emily,Serena,Tessa';for f in *.txt;do say -v "${a[$((RANDOM%${#a[@]}))]}" -f "$f" -o "${f%txt}aif";done
You can use ffmpeg to convert the files to mp3:
-aq 2
corresponds to-V2
inlame
. You can install ffmpeg withbrew install ffmpeg
after installing Homebrew.