Fix issues with set voice if the user hasn't run a game using sapi in that prefix yet

This commit is contained in:
Michael Taboada 2021-05-12 01:43:49 -07:00
parent e568f54571
commit 084f24578a

View File

@ -48,6 +48,12 @@
# Settings to improve accessibility of dialog. # Settings to improve accessibility of dialog.
export DIALOGOPTS='--insecure --no-lines --visit-items' export DIALOGOPTS='--insecure --no-lines --visit-items'
# Turn off debug messages
export WINEDEBUG="-all"
# Set DISPLAY, as needed
if [ -z "$DISPLAY" ] ; then
export DISPLAY=:0
fi
# Get the desired wine bottle # Get the desired wine bottle
@ -64,8 +70,6 @@ if [[ -z "${WINEPREFIX}" ]]; then
exit 0 exit 0
fi fi
echo "wineprefix = $WINEPREFIX"
msgbox() { msgbox() {
# Returns: None # Returns: None
# Shows the provided message on the screen with an ok button. # Shows the provided message on the screen with an ok button.
@ -171,6 +175,14 @@ EOF
doRestore=1 doRestore=1
trap restore_voice SIGINT trap restore_voice SIGINT
# In case the user hasn't run a game using sapi in this prefix yet, let's try to initialize all the registry keys properly.
cat << "EOF" > /tmp/speak.vbs
dim speechobject
set speechobject=createobject("sapi.spvoice")
speechobject.speak ""
EOF
wine cscript "z:\tmp\speak.vbs"
# Create an array of available voices. # Create an array of available voices.
ifs="$IFS" ifs="$IFS"
IFS=$'\n' IFS=$'\n'
@ -189,9 +201,6 @@ if [[ "$(uname)" == "Darwin" ]]; then
else else
oldVoice="$(grep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"' "${WINEPREFIX}/user.reg" | sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')" oldVoice="$(grep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"' "${WINEPREFIX}/user.reg" | sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')"
fi fi
echo "oldVoice: ${oldVoice}"
echo "voiceList: ${voiceList[@]}"
echo "voiceListFullName: ${voiceListFullName[@]}"
#exit 1 #exit 1
exit=1 exit=1
while [[ $exit -ne 0 ]] ; do while [[ $exit -ne 0 ]] ; do