Espeak now set as default voice for new installs. Install_espeak.sh helper script added in speech.
This commit is contained in:
Executable
+93
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
export WINEPREFIX="${WINEPREFIX:-${HOME}/.local/wine64}"
|
||||
export WINEDEBUG="${WINEDEBUG:--all}"
|
||||
|
||||
installerUrl="https://stormgames.wolfe.casa/downloads/winespeak.exe"
|
||||
installerName="winespeak.exe"
|
||||
installerSha256="187d4db69f3af7c1bca1c100a04489b76732048be7c38449781da360ed7b2d66"
|
||||
cacheDir="${XDG_CACHE_HOME:-${HOME}/.cache}/audiogame-manager"
|
||||
installerPath="${cacheDir}/${installerName}"
|
||||
partialPath="${installerPath}.part"
|
||||
wrapperPath="${WINEPREFIX}/drive_c/Program Files (x86)/espeak-ng-sapi/EspeakSAPI.dll"
|
||||
wrapperSha256="8009750dad82ca6665871814033dcee6844bb424f033130c109f47e188c5364b"
|
||||
voiceToken="HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices\\TokenEnums\\eSpeak-NG\\English (America)"
|
||||
|
||||
fail() {
|
||||
printf 'Error: %s\n' "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
require_command() {
|
||||
command -v "$1" > /dev/null 2>&1 || fail "Required command not found: $1"
|
||||
}
|
||||
|
||||
verify_sha256() {
|
||||
local file="$1"
|
||||
local expected="$2"
|
||||
local actual
|
||||
|
||||
actual="$(sha256sum "$file" | awk '{print $1}')"
|
||||
[[ "$actual" == "$expected" ]]
|
||||
}
|
||||
|
||||
download_installer() {
|
||||
mkdir -p "$cacheDir"
|
||||
|
||||
if [[ -s "$installerPath" ]] && verify_sha256 "$installerPath" "$installerSha256"; then
|
||||
printf 'Using cached WineSpeak installer.\n'
|
||||
return
|
||||
fi
|
||||
|
||||
rm -f "$installerPath" "$partialPath"
|
||||
printf 'Downloading WineSpeak...\n'
|
||||
if ! curl -L4 --fail --retry 3 --output "$partialPath" "$installerUrl"; then
|
||||
rm -f "$partialPath"
|
||||
fail 'Could not download WineSpeak.'
|
||||
fi
|
||||
|
||||
if ! verify_sha256 "$partialPath" "$installerSha256"; then
|
||||
rm -f "$partialPath"
|
||||
fail 'The downloaded WineSpeak installer failed its SHA-256 check.'
|
||||
fi
|
||||
|
||||
mv "$partialPath" "$installerPath"
|
||||
}
|
||||
|
||||
install_winespeak() {
|
||||
local registryOutput
|
||||
|
||||
download_installer
|
||||
|
||||
printf 'Installing WineSpeak into %s...\n' "$WINEPREFIX"
|
||||
if ! wine "$installerPath" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-; then
|
||||
fail 'WineSpeak installation failed.'
|
||||
fi
|
||||
|
||||
if [[ ! -f "$wrapperPath" ]]; then
|
||||
fail 'WineSpeak did not install its 32-bit SAPI wrapper.'
|
||||
fi
|
||||
if ! verify_sha256 "$wrapperPath" "$wrapperSha256"; then
|
||||
fail 'WineSpeak installed an unexpected 32-bit SAPI wrapper.'
|
||||
fi
|
||||
|
||||
printf 'Setting English (America) as the default SAPI voice...\n'
|
||||
if ! wine reg add 'HKCU\Software\Microsoft\Speech\Voices' \
|
||||
/v DefaultTokenId /t REG_SZ /d "$voiceToken" /f > /dev/null; then
|
||||
fail 'Could not set the default SAPI voice.'
|
||||
fi
|
||||
|
||||
registryOutput="$(wine reg query 'HKCU\Software\Microsoft\Speech\Voices' /v DefaultTokenId 2>/dev/null)"
|
||||
if ! grep -Fq "$voiceToken" <<< "$registryOutput"; then
|
||||
fail 'Could not verify the default SAPI voice.'
|
||||
fi
|
||||
|
||||
printf 'WineSpeak is installed and English (America) is the default SAPI voice.\n'
|
||||
}
|
||||
|
||||
for commandName in curl wine sha256sum awk grep; do
|
||||
require_command "$commandName"
|
||||
done
|
||||
|
||||
install_winespeak
|
||||
Reference in New Issue
Block a user