ADSS (Automatic Dubbing Shell Script) was made for a structured, user-friendliness-aimed Text-To-Speech conversion of many different "dubs" at once, in a Linux environment, with the only dependency being the libttspico-utils package (and its subdependencies if any).
Code: Select all
#!/bin/bash
# (C)2018 Gustavo 'Gustavo6046' Rehermann. The MIT license.
# (C) SVOX. All rights reserved. (right?)
echo # Blank lines are good for the eye!
depcheckees=("pico2wave")
dependencies=("libttspico-utils") # used for dependency check
checkpkg() {
if [[ $(dpkg-query -W -f='${Status}' $1) == "ok installed" ]]; then
return 0
else
return 1
fi
}
installdeps() {
echo "At least one dependency was not found!"
echo "Do you want to install them automatically"
echo "using apt-get? (y/n)"
read -p ":" -n1 -r
echo
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo " > Updating package list..."
echo
apt-get update -y
echo
echo
echo " > Done. Installing missing dependencies..."
echo
for dep in "${dependencies}"; do
if ! checkpkg $dep; then
echo " + ${dep}"
apt-get install -y $dep
fi
done
else
echo "Missing dependencies: aborting."
exit
fi
}
depcheck() {
for dep in "${depcheckees}"; do
if ! which $dep >/dev/null; then
installdeps
break
fi
done
}
depcheck
convert() {
if [[ -f "$1" ]]; then
fn=$(basename $1 | sed "s/\.[^.]*$//")
pico2wave -l=en-US -w="./out/${fn}.wav" "$(<"$1")"
echo "$1 converted to ./out/${fn}.wav successfully."
else
echo "$1 not found! Ignoring."
fi
}
forcehelp() {
(
echo "ADSS (Automatic Dubbing Shell Script) is a simple"
echo "script program that automatizes text to"
echo "speech, by taking a dubbing list (dubs.txt"
echo "in the current directory), and convert all"
echo "the listed dubs into WAV files in the output"
echo "folder."
echo
echo "Using it isn't too difficult:"
echo
echo " 1. Create two folders which you want to"
echo " set up:"
echo
echo " * ./dubs/ contains all the text files"
echo " you want to convert."
echo " * ./out/ will contain all the audio"
echo " output you'll eventually get."
echo
echo " 2. Place all the text files you want to"
echo " convert into the dubs/ folder, and"
echo " list all of their filenames (without"
echo " extension!!) into dubs.txt (in the"
echo " current folder). You might want to"
echo " use a listing command like ls for"
echo " this."
echo
echo " 3. Run this script!"
echo
echo "You can also modify the text files later on"
echo "and rerun this script just fine."
echo
echo "Alternatively to creating the dubs.txt list,"
echo "you can simply convert all the files inside the"
echo "input folder!"
echo
echo "(C)2018 Gustavo 'Gustavo6046' Rehermann. The MIT license."
echo "(C) SVOX. All rights reserved. (right?)"
echo
) | more
}
help() {
if [[ -t 1 ]]; then
echo "Do you want help? (y/n)"
read -p ":" -n1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
forcehelp
fi
fi
}
errhelp() {
echo "$1"
echo
help
}
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
forcehelp
exit
fi
if [[ ! -d "./dubs/" ]] || [[ ! -d "./out/" ]]; then
echo "Either the input (dubs/) or output (out/)"
echo "directory is missing! Do you want the script"
echo "to make them for you? (y/n)"
read -p ":" -n1 -r
echo
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
mkdir -p dubs
mkdir -p out
echo "Directories were succesfully created."
echo "Consider re-running the script once"
echo "you're set up (accept some help for"
echo "more details!)."
fi
echo
help
exit
fi
if [[ ! -f dubs.txt ]]; then
echo "No dubbing list found!"
echo
echo "Do you want the script to convert all the files"
echo "inside the input folder automatically for you? (y/n)"
read -p ":" -n1 -r
echo
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Converting every input file."
for p in ./dubs/*; do if [[ -f "$p" ]]; then
convert "$p"
fi; done
else
help
exit
fi
else
while read -r p; do
convert "./dubs/$p"
done <dubs.txt
fi
echo