X-Git-Url: http://njoseph.me/gitweb/babashka-scripts.git/blobdiff_plain/f1d839f5e616cf6f3b121c3b34a4fd16b2200a8c..HEAD:/ebook-to-audio-book.clj diff --git a/ebook-to-audio-book.clj b/ebook-to-audio-book.clj deleted file mode 100755 index c09b8d0..0000000 --- a/ebook-to-audio-book.clj +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env bb - -; A utility to listen to your ebooks using TTS programs - -(require '[babashka.process :as p] - '[clojure.java.io :as io] - '[clojure.string :refer [split]]) - -;; TODO Check if all required utilities are installed - -;; TODO Allow voice selection -(println "Selected voice is Samantha") - -;; TODO Use festival-tts or say depending on OS - -(defn run-cmd - [command] - (->> command - p/process - :out - slurp)) - -(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)))