From b61d876e317ac5e2a3321143ab0991821620f1e1 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 20 Aug 2024 01:34:11 -0400 Subject: [PATCH] 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. --- .scripts/FreeDoom.sh | 44 +++++++++++++++---- .scripts/TobyCustom/.projectbrutalityrc | 36 --------------- .scripts/TobyCustom/ArmyOfDarknessDoom.sh | 10 ----- .scripts/TobyCustom/Brutal_Death_Match.sh | 12 ----- .../Project_Brutality Latest_Operation_MDK.sh | 8 ---- .../Project_Brutality Latest_Toby_Deluxe.sh | 13 ------ .../Project_Brutality Latest_Toby_Demo.sh | 14 ------ .../Project_Brutality_Operation_MDK.sh | 12 ----- .../Project_Brutality_Toby_Deluxe.sh | 13 ------ .../TobyCustom/Project_Brutality_Toby_Demo.sh | 13 ------ .scripts/TobyCustom/StarWars.sh | 19 ++++++++ 11 files changed, 54 insertions(+), 140 deletions(-) delete mode 100644 .scripts/TobyCustom/.projectbrutalityrc create mode 100755 .scripts/TobyCustom/StarWars.sh diff --git a/.scripts/FreeDoom.sh b/.scripts/FreeDoom.sh index ca02f41..273a111 100755 --- a/.scripts/FreeDoom.sh +++ b/.scripts/FreeDoom.sh @@ -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 diff --git a/.scripts/TobyCustom/.projectbrutalityrc b/.scripts/TobyCustom/.projectbrutalityrc deleted file mode 100644 index d90045e..0000000 --- a/.scripts/TobyCustom/.projectbrutalityrc +++ /dev/null @@ -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/^\+//') diff --git a/.scripts/TobyCustom/ArmyOfDarknessDoom.sh b/.scripts/TobyCustom/ArmyOfDarknessDoom.sh index 9cdd8aa..4e0c815 100755 --- a/.scripts/TobyCustom/ArmyOfDarknessDoom.sh +++ b/.scripts/TobyCustom/ArmyOfDarknessDoom.sh @@ -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 diff --git a/.scripts/TobyCustom/Brutal_Death_Match.sh b/.scripts/TobyCustom/Brutal_Death_Match.sh index c991b83..58dadb0 100755 --- a/.scripts/TobyCustom/Brutal_Death_Match.sh +++ b/.scripts/TobyCustom/Brutal_Death_Match.sh @@ -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 diff --git a/.scripts/TobyCustom/Project_Brutality Latest_Operation_MDK.sh b/.scripts/TobyCustom/Project_Brutality Latest_Operation_MDK.sh index 81cadae..1372440 100755 --- a/.scripts/TobyCustom/Project_Brutality Latest_Operation_MDK.sh +++ b/.scripts/TobyCustom/Project_Brutality Latest_Operation_MDK.sh @@ -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 diff --git a/.scripts/TobyCustom/Project_Brutality Latest_Toby_Deluxe.sh b/.scripts/TobyCustom/Project_Brutality Latest_Toby_Deluxe.sh index dbe8659..cfb4f46 100755 --- a/.scripts/TobyCustom/Project_Brutality Latest_Toby_Deluxe.sh +++ b/.scripts/TobyCustom/Project_Brutality Latest_Toby_Deluxe.sh @@ -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 diff --git a/.scripts/TobyCustom/Project_Brutality Latest_Toby_Demo.sh b/.scripts/TobyCustom/Project_Brutality Latest_Toby_Demo.sh index 316a522..f4928e3 100755 --- a/.scripts/TobyCustom/Project_Brutality Latest_Toby_Demo.sh +++ b/.scripts/TobyCustom/Project_Brutality Latest_Toby_Demo.sh @@ -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 diff --git a/.scripts/TobyCustom/Project_Brutality_Operation_MDK.sh b/.scripts/TobyCustom/Project_Brutality_Operation_MDK.sh index 29a3b00..b3b00f5 100755 --- a/.scripts/TobyCustom/Project_Brutality_Operation_MDK.sh +++ b/.scripts/TobyCustom/Project_Brutality_Operation_MDK.sh @@ -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 diff --git a/.scripts/TobyCustom/Project_Brutality_Toby_Deluxe.sh b/.scripts/TobyCustom/Project_Brutality_Toby_Deluxe.sh index f52f1be..d212988 100755 --- a/.scripts/TobyCustom/Project_Brutality_Toby_Deluxe.sh +++ b/.scripts/TobyCustom/Project_Brutality_Toby_Deluxe.sh @@ -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 diff --git a/.scripts/TobyCustom/Project_Brutality_Toby_Demo.sh b/.scripts/TobyCustom/Project_Brutality_Toby_Demo.sh index f4b3585..3e01845 100755 --- a/.scripts/TobyCustom/Project_Brutality_Toby_Demo.sh +++ b/.scripts/TobyCustom/Project_Brutality_Toby_Demo.sh @@ -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 diff --git a/.scripts/TobyCustom/StarWars.sh b/.scripts/TobyCustom/StarWars.sh new file mode 100755 index 0000000..265cbf7 --- /dev/null +++ b/.scripts/TobyCustom/StarWars.sh @@ -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