Clean up set-voice script
This commit is contained in:
parent
f523b51327
commit
4db6eae6a0
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Set Voice
|
||||
# Set the default wine voice based on installed options.
|
||||
# Set the default wine voice ba$sed on installed options.
|
||||
# Rate can be specified as a numeric argument to this script, 1 through 9.
|
||||
# The default rate is 7
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
# ■The contents of this file are subject to the Common Public Attribution
|
||||
# License Version 1.0 (the ■License■); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# https://opensource.org/licenses/CPAL-1.0. The License is based on the Mozilla Public License Version
|
||||
# https://opensource.org/licenses/CPAL-1.0. The License is ba$sed on the Mozilla Public License Version
|
||||
# 1.1 but Sections 14 and 15 have been added to cover use of software over a
|
||||
# computer network and provide for limited attribution for the Original
|
||||
# Developer. In addition, Exhibit A has been modified to be consistent with
|
||||
@ -44,6 +44,13 @@
|
||||
|
||||
#--code--
|
||||
|
||||
# Set a variable to make mac compatibility easier...
|
||||
sed="sed"
|
||||
grep="grep"
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
sed="gsed"
|
||||
grep="ggrep"
|
||||
fi
|
||||
# Settings to improve accessibility of dialog.
|
||||
export DIALOGOPTS='--insecure --no-lines --visit-items'
|
||||
# Turn off debug messages
|
||||
@ -116,11 +123,7 @@ 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
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
gsed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
|
||||
else
|
||||
sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
|
||||
fi
|
||||
$sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -134,16 +137,10 @@ set_voice() {
|
||||
counter=$(( $counter + 1 ))
|
||||
done
|
||||
fullVoice="${voiceListFullName[$counter]}"
|
||||
fullVoice="${fullVoice/RHVoice/RHVoice\\\\bdl}"
|
||||
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
|
||||
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\\\\Token(Enum|)s\\\\[^"]+"/"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\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg"
|
||||
fi
|
||||
$sed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg"
|
||||
$sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg"
|
||||
}
|
||||
|
||||
test_voice() {
|
||||
@ -156,13 +153,8 @@ test_voice() {
|
||||
counter=$(( $counter + 1 ))
|
||||
done
|
||||
fullVoice="${voiceListFullName[$counter]}"
|
||||
fullVoice="${fullVoice/RHVoice/RHVoice\\\\bdl}"
|
||||
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\\\\Token(Enum|)s\\\\[^"]+"/"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\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
|
||||
fi
|
||||
$sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
|
||||
cat << "EOF" > /tmp/speak.vbs
|
||||
dim speechobject
|
||||
set speechobject=createobject("sapi.spvoice")
|
||||
@ -186,21 +178,13 @@ wine cscript "z:\tmp\speak.vbs"
|
||||
# Create an array of available voices.
|
||||
ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
voiceListFullName=($(ggrep -P '\[Software\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^\\]+\].*' "${WINEPREFIX}/system.reg" | sed -E -e 's/\[([^]]+)\].*/\1/g'))
|
||||
else
|
||||
voiceListFullName=($(grep -P '\[Software\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^\\]+\].*' "${WINEPREFIX}/system.reg" | sed -E -e 's/\[([^]]+)\].*/\1/g'))
|
||||
fi
|
||||
voiceListFullName=($($grep -P '\[Software\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^\\]+\].*' "${WINEPREFIX}/system.reg" | $sed -E -e 's/\[([^]]+)\].*/\1/g'))
|
||||
IFS="$ifs"
|
||||
voiceList=()
|
||||
for x in "${voiceListFullName[@]}" ; do
|
||||
voiceList+=("$(echo "$x" | rev | cut -d\\ -f1 | rev)")
|
||||
voiceList+=("$(echo "$x" | $sed -E -e 's/Software\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\(.+)/\1/g')")
|
||||
done
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
oldVoice="$(ggrep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"' "${WINEPREFIX}/user.reg" | sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')"
|
||||
else
|
||||
oldVoice="$(grep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"' "${WINEPREFIX}/user.reg" | sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')"
|
||||
fi
|
||||
oldVoice="$($grep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"' "${WINEPREFIX}/user.reg" | $sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')"
|
||||
exit=1
|
||||
while [[ $exit -ne 0 ]] ; do
|
||||
voice="$(menulist "${voiceList[@]}")"
|
||||
|
Loading…
Reference in New Issue
Block a user