Massive rewrite of how speaking with TTS is handled. This should open up compatibility with pretty much every wad out there as far as TTS is concerned. There may be unwanted speech until everything is ironed out.

This commit is contained in:
Storm Dragon 2024-08-20 01:34:11 -04:00
parent 3bdc8d6ead
commit b61d876e31
11 changed files with 54 additions and 140 deletions

View File

@ -1,5 +1,30 @@
#!/usr/bin/env bash
launch_game() {
pushd "${doomPath}"
exec stdbuf -oL ${gzdoom} ${@} | speak
popd
}
speak() {
startSpeech=1
while IFS= read -r line; do
echo "$line"
if [[ $startSpeech -eq 1 ]] && [[ "$line" =~ ^-{5,}$ ]]; then
startSpeech=0
continue
fi
if [[ $startSpeech -eq 0 ]]; then
echo "${line}" | {
grep "${antiGrepStrings[@]}" |
sed "${sedStrings[@]}" |
spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1;
}
echo "$line"
fi
done
}
# Dialog setup:
DIALOG_ITEM_HELP=""
export DIALOGOPTS='--no-lines --visit-items'
@ -48,10 +73,14 @@ doomGames=(
export antiGrepStrings=(
'-E' '-v'
'-e' '^(Decal|Fluidsynth|Load|Parse)[^ ]+'
'-e' '^OS: .*Linux, Linux .*'
'-e' '^Resolution:'
'-e' '^[0-9]'
'-e' '^P_StartScript:'
'-e' '^(Facing|INTRO|MAP[0-9]+|README[0-9]+)'
'-e' '^ *TITLEMAP'
'-e' '^\[Toby Accessibility Mod\] (INTRO|READMe)([0-9]+).*'
'-e' 'key card'
'-e' '^Computer voice:'
'-e' '^Ugh\.\.\. Huh\? What the hell was that\?! Better go check it out\.\.\.$'
)
export grepStrings=(
@ -217,8 +246,7 @@ case ${buttonCode} in
'-warp' "$map"
)
fi
pushd "$doomPath"
exec stdbuf -oL ${gzdoom} ${gameOption} "$gamePath/Addons/DOOM/TobyV${tobyVersion%%-*}_"* "${flags[@]}" | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} --; } ; echo "$l";done
launch_game ${gameOption} "${flags[@]}"
;;
2)
# Exit was pressed, so exit.
@ -270,15 +298,13 @@ case ${buttonCode} in
)
fi
pushd "${doomPath}"
exec stdbuf -oL ${gzdoom} ${gameOption} "$gamePath/Addons/TobyV${tobyVersion%%-*}_"* "${flags[@]}" | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} --; } ; echo "$l";done
launch_game ${gameOption} "${flags[@]}"
;;
0)
if [[ "${gameOption%% *}" == "custom_game" ]]; then
custom_game
else
pushd "${doomPath}"
exec stdbuf -oL ${gzdoom} ${gameOption} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done
fi
launch_game ${gameOption[@]} "${flags[@]}"
;;
esac

View File

@ -1,36 +0,0 @@
# Extend the search for new messages to be read.
grepStrings+=('-e' '^\*\*\* Brutality Bonus awarded!'
'-e' '^\+[0-9]+ '
'-e' '^A backpack for all your ammo storage needs!$'
'-e' '^Area survey map.$'
'-e' ' died.'
'-e' 'Ectoplasmic Surge!'
'-e' '^Game Saved.'
'-e' ' has been '
'-e' '^(Armor|Health) boosted!'
'-e' '(Greater|Lesser) demon energy'
'-e' '^Found '
'-e' 'Got the '
'-e' ' killed (her|him|it)self(\.|!)'
'-e' '^Low-light goggles.$'
'-e' '^Picked up '
'-e' '^Press '
'-e' 'Rescue operations suit.'
'-e' '^(Mega|Soul|Invulnerability )[Ss]phere!?$'
'-e' '^Mancubus '
'-e' ' skeleton key secured!$'
'-e' ' \(Slot [0-9]+\)'
'-e' ' (SPLATTERED|was) .*(\.|!)'
'-e' ' Swiss Cheese '
'-e' '^Took '
'-e' '^Vanguard of the gods!$'
'-e' "You've found "
'-e' 'You (collected|got|found|picked up) ')
antiGrepStrings+=('-e' 'key card'
'-e' '^\[Toby Accessibility Mod\] (INTRO|README)[0-9]+ .*'
'-e' ' was .*\?'
)
sedStrings+=('-e' 's/\*{3}//g'
'-e' 's/^\+//')

View File

@ -3,8 +3,6 @@
# requires aoddoom1.wad
# https://www.moddb.com/mods/army-of-darkness-total-conversion/addons/army-of-darkness-doom-wad
# Set the current path to the Doom path required by some OS.
pushd "${doomPath}"
gamePath=~/.local/games/doom
# Set up the pk3 and wad files
@ -22,11 +20,3 @@ if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol6.wad")
fi
# Source common variable extensions.
pbrc="$(find "${0%/*}/" -type f -name '.projectbrutalityrc')"
source "${pbrc}"
# Launch the game and pipe things to be spoken through speech-dispatcher.
# This also leaves the console output intact for people who may want to read it.
exec stdbuf -oL ${gzdoom} ${gameOption[@]} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done

View File

@ -1,9 +1,5 @@
#!/usr/bin/env bash
pushd "$doomPath"
gamePath=~/.local/games/doom
# Set up the pk3 and wad files
gameOption=(
"${gamePath}/TobyAccMod_V${tobyVersion}.pk3"
@ -104,11 +100,3 @@ if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=" DoomMetalVol6.wad"
fi
# Source common variable extensions.
pbrc="$(find "${0%/*}/" -type f -name '.projectbrutalityrc')"
source "${pbrc}"
# Launch the game and pipe things to be spoken through speech-dispatcher.
# This also leaves the console output intact for people who may want to read it.
exec stdbuf -oL ${gzdoom} ${gameOption[@]} "${flags[@]}" | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done

View File

@ -18,11 +18,3 @@ if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol6.wad")
fi
# Source common variable extensions.
pbrc="$(find "${0%/*}/" -type f -name '.projectbrutalityrc')"
source "${pbrc}"
# Launch the game and pipe things to be spoken through speech-dispatcher.
# This also leaves the console output intact for people who may want to read it.
exec stdbuf -oL ${gzdoom} ${gameOption[@]} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done

View File

@ -1,10 +1,5 @@
#!/usr/bin/env bash
# Set the current path to the Doom path required by some OS.
pushd "${doomPath}"
gamePath=~/.local/games/doom
# Set up the pk3 and wad files
gameOption=(
"${gamePath}/TobyAccMod_V${tobyVersion}.pk3"
@ -19,11 +14,3 @@ if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol6.wad")
fi
# Source common variable extensions.
pbrc="$(find "${0%/*}/" -type f -name '.projectbrutalityrc')"
source "${pbrc}"
# Launch the game and pipe things to be spoken through speech-dispatcher.
# This also leaves the console output intact for people who may want to read it.
exec stdbuf -oL ${gzdoom} ${gameOption[@]} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done

View File

@ -1,10 +1,4 @@
#!/usr/bin/env bash
# Set the current path to the Doom path required by some OS.
pushd "${doomPath}"
gamePath=~/.local/games/doom
# Set up the pk3 and wad files
gameOption=(
"${gamePath}/TobyAccMod_V${tobyVersion}.pk3"
@ -20,11 +14,3 @@ if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol6.wad")
fi
# Source common variable extensions.
pbrc="$(find "${0%/*}/" -type f -name '.projectbrutalityrc')"
source "${pbrc}"
# Launch the game and pipe things to be spoken through speech-dispatcher.
# This also leaves the console output intact for people who may want to read it.
exec stdbuf -oL ${gzdoom} ${gameOption[@]} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done

View File

@ -1,9 +1,5 @@
#!/usr/bin/env bash
# Set the current path to the Doom path required by some OS.
pushd "${doomPath}"
gamePath=~/.local/games/doom
# Set up the pk3 and wad files
gameOption=(
"${gamePath}/TobyAccMod_V${tobyVersion}.pk3"
@ -19,11 +15,3 @@ if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol6.wad")
fi
# Source common variable extensions.
pbrc="$(find "${0%/*}/" -type f -name '.projectbrutalityrc')"
source "${pbrc}"
# Launch the game and pipe things to be spoken through speech-dispatcher.
# This also leaves the console output intact for people who may want to read it.
exec stdbuf -oL ${gzdoom} ${gameOption[@]} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done

View File

@ -1,10 +1,5 @@
#!/usr/bin/env bash
# Set the current path to the Doom path required by some OS.
pushd "${doomPath}"
gamePath=~/.local/games/doom
# Set up the pk3 and wad files
gameOption=(
"${gamePath}/TobyAccMod_V${tobyVersion}.pk3"
@ -20,11 +15,3 @@ if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol6.wad")
fi
# Source common variable extensions.
pbrc="$(find "${0%/*}/" -type f -name '.projectbrutalityrc')"
source "${pbrc}"
# Launch the game and pipe things to be spoken through speech-dispatcher.
# This also leaves the console output intact for people who may want to read it.
exec stdbuf -oL ${gzdoom} ${gameOption[@]} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done

View File

@ -1,10 +1,5 @@
#!/usr/bin/env bash
# Set the current path to the Doom path required by some OS.
pushd "${doomPath}"
gamePath=~/.local/games/doom
# Set up the pk3 and wad files
gameOption=(
"${gamePath}/TobyAccMod_V${tobyVersion}.pk3"
@ -20,11 +15,3 @@ if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol6.wad")
fi
# Source common variable extensions.
pbrc="$(find "${0%/*}/" -type f -name '.projectbrutalityrc')"
source "${pbrc}"
# Launch the game and pipe things to be spoken through speech-dispatcher.
# This also leaves the console output intact for people who may want to read it.
exec stdbuf -oL ${gzdoom} ${gameOption[@]} | while IFS= read -r l ; do echo "$l" | { grep "${grepStrings[@]}" | grep "${antiGrepStrings[@]}" | sed "${sedStrings[@]}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; }; echo "$l";done

19
.scripts/TobyCustom/StarWars.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Extend sed strings to handle the player class menu
sedStrings+=('-e' 's/^Playerclassmenu$/Player class menu/')
# Set up the pk3 and wad files
gameOption=(
"${gamePath}/TobyAccMod_V${tobyVersion}.pk3"
"$gamePath/Addons/MENU/TobyV${tobyVersion%%-*}_"*
"${gamePath}/OpMDK.wad"
"${gamePath}/Xim-StarWars-v3.1.5.pk3"
"$gamePath/Addons/STARWARS/"*
)
# Check for and include if present a wad. Some people may not have it.
if [[ -e "${gamePath}/DoomMetalVol7.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol7.wad")
elif [[ -e "${gamePath}/DoomMetalVol6.wad" ]]; then
gameOption+=("${gamePath}/DoomMetalVol6.wad")
fi