-; This utility only works on macOS for now.
-
-(require '[clojure.java.io :as io]
- '[clojure.string :refer [split]]
- '[lib :refer [run-cmd extract-file-from-zip unixify]])
+; Dependencies:
+; 1. calibre
+; 2. ffmpeg
+; 3. OS-dependent TTS software
-;; TODO Use festival-tts or say depending on OS
-
-(defn- convert
+;; TODO Use tools.cli to provide more options
+(defn convert-ebook-to-audiobook
+ "A utility to listen to your ebooks using TTS programs. This utility only works on macOS for now."
(let [title (first (split book-file #"\."))
txtz-file (str title ".txtz")
txt-file (str title ".txt")
(let [title (first (split book-file #"\."))
txtz-file (str title ".txtz")
txt-file (str title ".txt")
(run-cmd ["ebook-convert" book-file txtz-file])
(extract-file-from-zip txtz-file "index.txt" txt-file)
(println "Converting text to audio. Don't hold your breath!")
(run-cmd ["ebook-convert" book-file txtz-file])
(extract-file-from-zip txtz-file "index.txt" txt-file)
(println "Converting text to audio. Don't hold your breath!")
(run-cmd ["say" "-f" txt-file "-o" aiff-file])
(println "Creating mp3 file...")
(run-cmd ["ffmpeg" "-i" aiff-file mp3-file])
(println "Cleaning up...")
(run! io/delete-file [txtz-file txt-file aiff-file])
(println (str "Done! Check out " mp3-file))))
(run-cmd ["say" "-f" txt-file "-o" aiff-file])
(println "Creating mp3 file...")
(run-cmd ["ffmpeg" "-i" aiff-file mp3-file])
(println "Cleaning up...")
(run! io/delete-file [txtz-file txt-file aiff-file])
(println (str "Done! Check out " mp3-file))))