X-Git-Url: https://njoseph.me/gitweb/babashka-scripts.git/blobdiff_plain/00a9627659403ac2a910f8753cc2b1510384d6c3..76cc62f08f19febed3fe9025a8315c3486fcd214:/ebook-to-audio-book.clj diff --git a/ebook-to-audio-book.clj b/ebook-to-audio-book.clj index 39da869..48eb115 100755 --- a/ebook-to-audio-book.clj +++ b/ebook-to-audio-book.clj @@ -4,7 +4,7 @@ (require '[clojure.java.io :as io] '[clojure.string :refer [split]] - '[lib :refer [run-cmd extract-file-from-zip]]) + '[lib :refer [run-cmd extract-file-from-zip unixify]]) ;; TODO Check if all required utilities are installed @@ -13,19 +13,22 @@ ;; TODO Use festival-tts or say depending on OS -(let [book-file (first *command-line-args*) - title (first (split book-file #"\.")) - txtz-file (str title ".txtz") - txt-file (str title ".txt") - aiff-file (str title ".aiff") - mp3-file (str title ".mp3")] - (println "Converting to text...") - (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))) +(defn- convert + [book-file] + (let [title (first (split book-file #"\.")) + txtz-file (str title ".txtz") + txt-file (str title ".txt") + aiff-file (str title ".aiff") + mp3-file (str title ".mp3")] + (println "Converting to text...") + (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)))) + +(unixify convert)