From 084f24578a035396b3b92d53d07064a7fb922534 Mon Sep 17 00:00:00 2001 From: Michael Taboada Date: Wed, 12 May 2021 01:43:49 -0700 Subject: [PATCH] Fix issues with set voice if the user hasn't run a game using sapi in that prefix yet --- speech/set-voice.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/speech/set-voice.sh b/speech/set-voice.sh index 4712eac..eefc37d 100755 --- a/speech/set-voice.sh +++ b/speech/set-voice.sh @@ -48,6 +48,12 @@ # Settings to improve accessibility of dialog. 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 @@ -64,8 +70,6 @@ if [[ -z "${WINEPREFIX}" ]]; then exit 0 fi -echo "wineprefix = $WINEPREFIX" - msgbox() { # Returns: None # Shows the provided message on the screen with an ok button. @@ -171,6 +175,14 @@ EOF doRestore=1 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. ifs="$IFS" IFS=$'\n' @@ -189,9 +201,6 @@ if [[ "$(uname)" == "Darwin" ]]; then 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')" fi -echo "oldVoice: ${oldVoice}" -echo "voiceList: ${voiceList[@]}" -echo "voiceListFullName: ${voiceListFullName[@]}" #exit 1 exit=1 while [[ $exit -ne 0 ]] ; do