-
Notifications
You must be signed in to change notification settings - Fork 0
/
abook-make
executable file
·37 lines (29 loc) · 1010 Bytes
/
abook-make
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
set -o errexit
set -o functrace
set -o nounset
SCRIPTS="$HOME/scripts"
SCRIPT_RHVOICE_FIXED="$SCRIPTS/rhvoice-fixed.sh"
SCRIPT_RHVOICE_FIX_FILE="$SCRIPTS/rhvoice-fix-file.sh"
if [ "$#" -lt 1 ]; then
echo "Usage: create-abook SOURCE"
exit
fi
function parse_extension { FILE_NAME_WITH_EXT="$1"
echo "$FILE_NAME_WITH_EXT" | rev | cut -f 1 -d '.' | rev
}
function parse_file_name_no_ext { FILE_NAME_WITH_EXT="$1"
EXTENSION=$(parse_extension "$FILE_NAME_WITH_EXT")
#echo "DEBUG: parse_file_name_no_ext: EXTENSION: $EXTENSION"
echo "$FILE_NAME_WITH_EXT" | sed -e s/\.${EXTENSION}$//g
}
SOURCE_PATH="$1"
SOURCE_PATH_NO_EXT=$(parse_file_name_no_ext "$1")
FIXED_FILE_DEBUG_PATH="$SOURCE_PATH.rhvoice-fixed"
DEST_PATH="$SOURCE_PATH_NO_EXT.mp3"
cat "$SOURCE_PATH" | "$SCRIPT_RHVOICE_FIX_FILE" > "$FIXED_FILE_DEBUG_PATH"
(
set -x;
cat "$SOURCE_PATH" | "$SCRIPT_RHVOICE_FIXED" | lame -b 192 -q 0 - "$DEST_PATH"
)