Somewhat rewrite install cepstral to be cleaner and more easily maintainable.

This commit is contained in:
Michael Taboada 2021-05-12 00:51:03 -07:00
parent b268683c01
commit fe642e96fa

View File

@ -10,11 +10,15 @@
export DIALOGOPTS='--no-lines --visit-items'
# Make sure display is set in case installed from console.
export DISPLAY="${DISPLAY:-:0}"
# Version number, to easily keep script up-to-date.
version="6.2.3.801"
# Msi or exe? Some are different.
msiexe="exe"
# Beginning part of url, for making things easier.
prefix="https://www.cepstral.com/downloads/installers/windows/"
register() {
local v="${1##*Cepstral_}"
v="${v%%_*}"
local v="$1"
company="$(dialog --clear --inputbox "Company name (leave empty if none)" -1 -1 --stdout)" || exit $?
customer="$(dialog --clear --inputbox "Customer name" -1 -1 --stdout)" || exit $?
key="$(dialog --clear --inputbox "License key" -1 -1 --stdout)" || exit $?
@ -25,48 +29,48 @@ register() {
action="install"
declare -a voices=(
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Allison_windows_6.2.3.801.exe"
"Allison"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Amy_windows_6.2.3.801.exe"
"Allison"
"Amy"
"Amy"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Belle_windows_6.2.3.801.exe"
"Belle"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Callie_windows_6.2.3.801.exe"
"Belle"
"Callie"
"Callie"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Charlie_windows_6.2.3.801.exe"
"Charlie"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Dallas_windows_6.2.3.801.exe"
"Charlie"
"Dallas"
"Dallas"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Damien_windows_6.2.3.801.exe"
"Damien"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_David_windows_6.2.3.801.exe"
"Damien"
"David"
"David"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Diane_windows_6.2.3.801.exe"
"Diane"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Duchess_windows_6.2.3.801.exe"
"Diane"
"Duchess"
"Duchess"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Duncan_windows_6.2.3.801.exe"
"Duncan"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Emily_windows_6.2.3.801.exe"
"Duncan"
"Emily"
"Emily"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Linda_windows_6.2.3.801.exe"
"Linda"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Robin_windows_6.2.3.801.exe"
"Linda"
"Robin"
"Robin"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Shouty_windows_6.2.3.801.exe"
"Shouty"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Walter_windows_6.2.3.801.exe"
"Shouty"
"Walter"
"Walter"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_Whispery_windows_6.2.3.801.exe"
"Whispery"
"https://www.cepstral.com/downloads/installers/windows/Cepstral_William_windows_6.2.3.801.exe"
"Whispery"
"William"
"William"
)
# Get the desired wine bottle
declare -a bottle
for i in $(find ~/.local/wine -maxdepth 1 -type d -not -name 'wine' | sort) ; do
for i in $(find ~/.local/wine/ -maxdepth 1 -type d -not -name 'wine' | sort) ; do
bottle+=("$i" "${i##*/}")
done
export WINEPREFIX="$(dialog --backtitle "Use the up and down arrow keys to find the option you want, then press enter to select it." \
@ -89,20 +93,25 @@ voice="$(dialog --backtitle "Use the up and down arrow keys to find the option y
--no-tags \
--menu "Select A voice to $action" 0 0 0 "${voices[@]}" --stdout)"
if [[ "$1" == "-r" || "$1" == "--register" ]]; then
if [[ "$action" == "register" ]]; then
register $voice
fi
# make sure the ~/Downloads directory exists.
mkdir -p ~/Downloads
if ! [[ -e ~/Downloads/${voice##*/} ]]; then
wget -O ~/Downloads/${voice##*/} "$voice" | dialog --progressbox "Download voice..." -1 -1
if ! [[ -e ~/Downloads/Cepstral_${voice}_windows_${version}.${msiexe} ]]; then
wget -P ~/Downloads/ "${prefix}Cepstral_${voice}_windows_${version}.${msiexe}" | dialog --progressbox "Downloading voice..." -1 -1
fi
# Get the install command.
cmd="wine"
[ "$msiexe" = "msi" ] && cmd="${cmd} msiexec /i"
cmd="${cmd} ~/Downloads/Cepstral_${voice}_windows_${version}.${msiexe}"
[ "$msiexe" = "msi" ] && cmd="${cmd} /q"
# Install the voice
(wine ~/Downloads/${voice##*/} &
xdotool sleep 20 key --delay 75 alt+n key --delay 75 alt+a key --delay 75 alt+n key --delay 75 alt+o key --delay 75 alt+i sleep 20 key --delay 75 alt+f
(eval "$cmd" &
[ "$msiexe" = "exe" ] && xdotool sleep 20 key --delay 75 alt+n key --delay 75 alt+a key --delay 75 alt+n key --delay 75 alt+o key --delay 75 alt+i sleep 20 key --delay 75 alt+f
find "${WINEPREFIX}/drive_c/Program Files/Cepstral/voices" -type d -not -name voices -exec bash -c 'for d ; do echo "GAIN 2.5" > "$d/default.sfx";done' _ {} \;) | dialog --progressbox "installing voice..." -1 -1
exit 0