]>
Commit | Line | Data |
---|---|---|
fa20f4c6 JN |
1 | #! /usr/bin/env bb |
2 | ||
3 | ; A utility to listen to your ebooks using TTS programs | |
4 | ||
67d5a15a JN |
5 | (require '[clojure.java.io :as io] |
6 | '[clojure.string :refer [split]] | |
76cc62f0 | 7 | '[lib :refer [run-cmd extract-file-from-zip unixify]]) |
fa20f4c6 JN |
8 | |
9 | ;; TODO Check if all required utilities are installed | |
10 | ||
11 | ;; TODO Allow voice selection | |
12 | (println "Selected voice is Samantha") | |
13 | ||
14 | ;; TODO Use festival-tts or say depending on OS | |
15 | ||
76cc62f0 JN |
16 | (defn- convert |
17 | [book-file] | |
18 | (let [title (first (split book-file #"\.")) | |
19 | txtz-file (str title ".txtz") | |
20 | txt-file (str title ".txt") | |
21 | aiff-file (str title ".aiff") | |
22 | mp3-file (str title ".mp3")] | |
23 | (println "Converting to text...") | |
24 | (run-cmd ["ebook-convert" book-file txtz-file]) | |
25 | (extract-file-from-zip txtz-file "index.txt" txt-file) | |
26 | (println "Converting text to audio. Don't hold your breath!") | |
27 | (run-cmd ["say" "-f" txt-file "-o" aiff-file]) | |
28 | (println "Creating mp3 file...") | |
29 | (run-cmd ["ffmpeg" "-i" aiff-file mp3-file]) | |
30 | (println "Cleaning up...") | |
31 | (run! io/delete-file [txtz-file txt-file aiff-file]) | |
32 | (println (str "Done! Check out " mp3-file)))) | |
33 | ||
34 | (unixify convert) |