From 6401a61cacde14a0223db0234d6c06c6d20b2f33 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 12 Dec 2020 02:46:08 -0500 Subject: [PATCH] Updated set fvoice script to work with gsed on mac. --- speech/set-voice.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/speech/set-voice.sh b/speech/set-voice.sh index e736f34..946cccb 100755 --- a/speech/set-voice.sh +++ b/speech/set-voice.sh @@ -91,7 +91,11 @@ menulist() { restore_voice() { if [[ $doRestore -eq 0 ]]; then wineserver -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely - sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" + if [[ "$(uname)" == "Darwin" ]]; then + gsed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" + else + sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" + fi fi } @@ -107,8 +111,13 @@ set_voice() { fullVoice="${voiceListFullName[$counter]}" wineserver -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely # Remove any existing rate change for voices - sed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg" - sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg" + if [[ "$(uname)" == "Darwin" ]]; then + gsed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg" + gsed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg" + else + sed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg" + sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg" + fi } test_voice() { @@ -122,7 +131,11 @@ test_voice() { done fullVoice="${voiceListFullName[$counter]}" wineserver -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely + if [[ "$(uname)" == "Darwin" ]]; then + gsed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" + else sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" + fi cat << "EOF" > /tmp/speak.vbs dim speechobject set speechobject=createobject("sapi.spvoice")