First of all, you need some software to install – you can use terminal and brew.
brew install --cask calibre
brew install lame
In Calibre open your e-book and convert it into a text file. Use Convert books → Convert individually → Output format: TXT → OK.
Now you have a text file without any formatting tags. You can remove/move to the end texts you don’t want to hear—like copyright info, ISBN, publisher notes, etc.
Your macOS have very useful command say. For how to install other voices see the support Apple page for your OS version.
You can select the voice, you prefer with parameter -v. In my case, I select the Czech voice → Zuzana.
say -v zuzana
And now is the time for some “magic”. In the terminal get into the directory, where is your ebook text file and run this command where mybook is the name of your text file and myaudio is the name of the output you want.
say -f mybook.txt -o myaudio.aiff
And wait… If you have a lot of space on your disk, you can stop here. Audio Interchange File Format in my case has 1.57 GB. But after conversion with lame
lame -m m myaudio.aiff myaudio.mp3
it has 142.6 MB. That is a lot of space to save. If you need to save more space or you prefer other settings for spoken word, use
lame --longhelp
and tweak the conversion command. For example, you can specify bitrate, add ID3 tags, define filter options, etc.