#!/bin/sh -e
# The script to create speech book from provided text file by Textlus utility and RHVoice speech synthesizer
# Michael Pozhidaev <msp@altlinux.org>

THIS="${0##*/}"

[ -z "$1" ] && echo "$THIS:No text file is mentioned in command line" >&2 && exit 1
if [ "$1" == '--help' ]; then
cat <<EOF
$THIS: The script to create speech book from provided text file by RHVoice speech synthesizer
Just run $THIS and give the name of the text file to read!
EOF
    exit 0
fi

[ -e .mp3-book-current-part ] && echo "$THIS:you already have the mp3-book process in this directory" >&2 && exit 1
echo 1 > .mp3-book-current-part

~/git/textlus.git/textlus -s make-mp3-book-impl "$1"
make-mp3-book-impl --final
echo 'Your mp3 book has been created!'
