talkwith vs speak-with messages language
Didier Spaier
didier at slint.fr
Tue Jan 12 18:06:23 EST 2021
Le 12/01/2021 à 23:13, Samuel Thibault a écrit :
> They are on this very list (speakup at linux-speakup.org)
So please, readers of this thread having users of talkwith and
speakupconf, try these scripts and let us know what you think.
>> It is. these commands should be replaced if another init system.
>>
>> This shouldn't be difficult, but I have zero experience with other init
>> systems
>
> Experience is something that can be acquired.
Maybe by young folks. I'm nearly 72y old...
This being said, assuming hat most readers are using systemd,
maybe they just can replace for instance in speak-with:
chmod 644 /etc/rc.d/rc.espeakup
by
systemctl disable espeakup.service
chmod 755 /etc/rc.d/rc.espeakup
by
systemctl disable espeakup.service
sh /etc/rc.d/rc.espeakup start
by
systemctl start espeakup.service
sh /etc/rc.d/rc.espeakup stop
by
systemctl stop espeakup.service
PS I just realized that the syntax in this line of speakup-save and
speakup-restore:
SYNTH=$(</sys/accessibility/speakup/synth)
is not specified by POSIX
I should have written instead:
SYNTH=$(cat /sys/accessibility/speakup/synth)
I reattach the (corrected) scripts to this email with for convenience.
Didier
-------------- next part --------------
#!/bin/sh
if [ ! $(id -u) -eq 0 ]; then
gettext -s "Please run this script as root."
exit
fi
if [ ! -f /sys/accessibility/speakup/synth ]; then
gettext -s "speakup being not in use, there is no setting to save."
exit
fi
SYNTH=$(cat /sys/accessibility/speakup/synth)
if [ "$SYNTH" = "none" ]; then
gettext -s "speakup being not in use, there is no setting to save."
exit
fi
ESPEAKUP=$(ps -C espeakup --noheaders|wc -l)
SPEECHD_UP=$(ps -C speechd-up --noheaders|wc -l)
# We save settings separately for:
# espeakup
# each hard synthesizer
# speechd-up
# so that we restore the relevant settings for the synthesizer and
# case occurring the screen reader in use.
if [ "$SYNTH" = "soft" ] && [ $ESPEAKUP -ne 0 ] && [ $SPEECHD_UP -ne 0 ]; then
gettext -s "espeakup and speechd-up are both running, not saving settings."
exit
fi
if [ "$SYNTH" = "soft" ] && [ $ESPEAKUP -eq 0 ] && [ $SPEECHD_UP -eq 0 ]; then
gettext -s "neither espeakup nor speechd-up is running, not saving settings."
exit
fi
if [ "$SYNTH" = "soft" ] && [ $ESPEAKUP -ne 0 ]; then
SYNTH="espeakup"
fi
if [ "$SYNTH" = "soft" ] && [ $SPEECHD_UP -ne 0 ]; then
SYNTH="speechd-up"
fi
# If SYNTH has not been set to speechd-up or speakup it is the hard synth
# in use.
mkdir -p /var/lib/speakup/$SYNTH
cd /sys/accessibility/speakup
for i in $(find . -type d|sed "/^.$/d;s/..//"); do
mkdir -p /var/lib/speakup/$SYNTH/$i
done
for i in $(find . -type f|sed "s/..//"|grep -v -e silent -e version -e "synth.*"); do
if [ -f $i ] && [ -w $i ]; then
cp $i /var/lib/speakup/$SYNTH/$i
fi
done
gettext "Current speakup settings have been saved in "
echo "/var/lib/speakup/$SYNTH."
-------------- next part --------------
#!/bin/sh
if [ ! $(id -u) -eq 0 ]; then
gettext -s "Please run this script as root."
exit
fi
if [ ! -f /sys/accessibility/speakup/synth ]; then
gettext -s "speakup being not in use, there is no setting to restore."
exit
elif [ "$(</sys/accessibility/speakup/synth)" = "none" ]; then
gettext -s "speakup being not in use, there is no setting to restore."
exit
fi
SYNTH=$(cat /sys/accessibility/speakup/synth)
ESPEAKUP=$(ps -C espeakup --noheaders|wc -l)
SPEECHD_UP=$(ps -C speechd-up --noheaders|wc -l)
# We saved settings separately for:
# espeakup
# each hard synthesizer
# speechd-up
# so that we restore the relevant settings for the synthesizer and
# screen reader in use.
SAVEDSYNTH="$SYNTH"
if [ "$SYNTH" = "soft" ] && [ $ESPEAKUP -ne 0 ]; then
SAVEDSYNTH="espeakup"
fi
if [ "$SYNTH" = "soft" ] && [ $SPEECHD_UP -ne 0 ]; then
SAVEDSYNTH="speechd-up"
fi
# If SYNTH has not been set to speechd-up or speakup a hard synth is
# in use, like e.g. SAVEDSYNTH=apollo
if [ ! -d /var/lib/speakup/$SAVEDSYNTH ]; then
gettext -s "No speakup settings saved for $SAVEDSYNTH, so nothing to restore."
exit
fi
cd /var/lib/speakup/$SAVEDSYNTH
ls|while read i; do
if [ -w /sys/accessibility/speakup/$i ] && [ -f /sys/accessibility/speakup/$i ]; then
cp $i /sys/accessibility/speakup/
fi
done
if [ -d i18n ] && [ -d /sys/accessibility/speakup/i18n ]; then
( cd i18n
ls|while read i; do
if [ -w /sys/accessibility/speakup/i18n/$i ]; then
cp $i /sys/accessibility/speakup/i18n/
fi
done
)
fi
( cd $SYNTH
ls|while read i; do
if [ -w /sys/accessibility/speakup/$SYNTH/$i ]; then
cp $i /sys/accessibility/speakup/$SYNTH/
fi
done
)
gettext -s "speakup settings have been restored for $SAVEDSYNTH."
-------------- next part --------------
#!/bin/sh
# Didier Spaier <didier~at~slint.fr> 2019
# I wrote this script from scratch and put it in the public domain.
# I assume that the packages espeakup and speechd-up are installed.
# If fenrir is installed, it can also be used.
if [ ! $(id -u) -eq 0 ]; then
echo "Please run this script as root."
exit
fi
speakup=" a hard synthesizer (type its name, like \"apollo\" or \"acntsa\")"
if [ -x /usr/bin/espeakup ]; then
espeakup=" espeakup (Console screen reader connecting espeak-ng and speakup)\n"
n1="espeakup"
fi
if [ -x /usr/bin/speechd-up ]; then
speechd_up=" speechd-up (Console screen reader connecting Speech Dispatcher and speakup)"
n2="speechd-up"
fi
if [ -x /usr/bin/fenrir ]; then
fenrir=" fenrir (Modular, flexible and fast console screen reader)\n"
n3="fenrir"
fi
readers="$espeakup$fenrir$speechd_up"
hardlist="$(zgrep SPEAKUP_S /proc/config.gz|grep [ym]|grep -v DUMMY| \
sed 's/CONFIG_SPEAKUP_SYNTH_//;s/..$//'|tr '[:upper:]' '[:lower:]')"
usage() {
echo "Usage: $0 <screen reader> or <hard synthesizer> or none"
echo "Choose a console screen reader to talk with among:"
echo -e "$readers"
echo "or use one of the supported hard synthesizers:"
echo " "$hardlist
echo "or type \"$0 none\" to mute all screen readers."
exit
}
to_lower() {
echo "$1"|tr '[:upper:]' '[:lower:]'
}
ARGUMENT=$(to_lower $1)
if [ $# -ne 1 ]; then usage; fi
if [ ! "$ARGUMENT" = "$n1" ] && \
[ ! "$ARGUMENT" = "$n2" ] && \
[ ! "$ARGUMENT" = "$n3" ] && \
! echo $hardlist| grep -qw $ARGUMENT && \
[ ! "$ARGUMENT" = "none" ]; then
echo "$1 is not a valid argument of this command."
usage
exit
fi
# We first check which console screen reader is already running, if any.
if [ ! "$(ps -C fenrir --noheaders|wc -l)" = "0" ]; then
FENRIR=y
fi
if [ -f /sys/accessibility/speakup/synth ]; then
SPKSYNTH=$(cat /sys/accessibility/speakup/synth)
if [ "$SPKSYNTH" = "soft" ]; then
if [ ! "$(ps -C speechd-up --noheaders|wc -l)" = "0" ]; then
SPEECHDUP="y"
fi
if [ ! "$(ps -C espeakup --noheaders|wc -l)" = "0" ]; then
ESPEAKUP="y"
fi
else
HARD=$SPKSYNTH
fi
fi
# If a hard synth is in use store its name as we need to override it to
# use a soft synth instead if wished, but we need to restore it if the
# user does not want a permanent change.
if [ -f /etc/speakup.conf ]; then
. /etc/speakup.conf
fi
case $ARGUMENT in
espeakup)
if [ ! -x /usr/bin/espeakup ]; then
echo "espeakup is not installed."
exit
fi
if [ "$ESPEAKUP" = "y" ]; then
echo "$1 is already started."
exit
fi
if [ "$FENRIR" = "y" ]; then
[ -f /etc/rc.d/rc.fenrir ] && sh /etc/rc.d/rc.fenrir stop
fi
if [ "$SPEECHDUP" = "y" ]; then
sh /etc/rc.d/rc.speechd-up stop
fi
echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
echo "hard=none" >> /etc/speakup.conf
sh /etc/rc.d/rc.espeakup start
sleep 1
printf "Should espeakup be also started at next boot? [Y/n] "
read ANSWER
if [ ! "$(to_lower $ANSWER)" = "n" ]; then
chmod 755 /etc/rc.d/rc.espeakup
chmod 644 /etc/rc.d/rc.speechd-up
[ -f /etc/rc.d/rc.fenrir ] && chmod 644 /etc/rc.d/rc.fenrir
echo "Done."
elif [ ! "$hard" = "" ]; then
echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
echo hard=$hard >> /etc/speakup.conf
fi
;;
speechd-up)
if [ ! -x /usr/bin/speechd-up ]; then
echo "speechd-up is not installed."
exit
fi
if [ "$SPEECHDUP" = "y" ]; then
echo "speechd-up is already started."
exit
fi
if [ "$FENRIR" = "y" ]; then
sh /etc/rc.d/rc.fenrir stop
fi
if [ "$ESPEAKUP" = "y" ]; then
sh /etc/rc.d/rc.espeakup stop
fi
echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
echo "hard=none" >> /etc/speakup.conf
sh /etc/rc.d/rc.speechd-up start
sleep 1
printf "Should speechd-up be also started at next boot? [Y/n] "
read ANSWER
if [ ! "$(to_lower $ANSWER)" = "n" ]; then
chmod 644 /etc/rc.d/rc.espeakup
[ -f /etc/rc.d/rc.fenrir ] && chmod 644 /etc/rc.d/rc.fenrir
chmod 755 /etc/rc.d/rc.speechd-up
echo "Done."
elif [ ! "$hard" = "" ]; then
echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
echo hard=$hard >> /etc/speakup.conf
fi
;;
fenrir)
if [ ! -x /usr/bin/fenrir ]; then
echo "fenrir is not installed."
exit
fi
if [ "$FENRIR" = "y" ]; then
echo "fenrir is already started."
exit
fi
if [ "$SPEECHDUP" = "y" ]; then
sh /etc/rc.d/rc.speechd-up stop
fi
if [ "$ESPEAKUP" = "y" ]; then
sh /etc/rc.d/rc.espeakup stop
fi
if [ ! "$SPKSYNTH" = "" ]; then
echo none > /sys/accessibility/speakup/synth
fi
echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
echo "hard=none" >> /etc/speakup.conf
sh /etc/rc.d/rc.fenrir start
sleep 1
clear
printf "Should fenrir be also started at boot time? [Y/n] "
read ANSWER
if [ ! "$(to_lower $ANSWER)" = "n" ]; then
chmod 644 /etc/rc.d/rc.espeakup
chmod 644 /etc/rc.d/rc.speechd-up
chmod 755 /etc/rc.d/rc.fenrir
echo "Done."
elif [ ! "$hard" = "" ]; then
echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
echo hard=$hard >> /etc/speakup.conf
fi
;;
none)
if [ "$FENRIR" = "y" ]; then
sh /etc/rc.d/rc.fenrir stop
fi
if [ "$ESPEAKUP" = "y" ]; then
sh /etc/rc.d/rc.espeakup stop
fi
if [ "$SPEECHDUP" = "y" ]; then
sh /etc/rc.d/rc.speechd-up stop
fi
if [ ! "$SPKSYNTH" = "" ]; then
echo none > /sys/accessibility/speakup/synth
fi
printf "Do you also want a mute console at next boot? [Y/n] "
read ANSWER
if [ ! "$(to_lower $ANSWER)" = "n" ]; then
chmod 644 /etc/rc.d/rc.espeakup
chmod 644 /etc/rc.d/rc.speechd-up
[ -f /etc/rc.d/rc.fenrir ] && chmod 644 /etc/rc.d/rc.fenrir
echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
echo "hard=none" >> /etc/speakup.conf
echo "OK"
fi
;;
*)
if [ "$FENRIR" = "y" ]; then
sh /etc/rc.d/rc.fenrir stop
fi
if [ "$ESPEAKUP" = "y" ]; then
sh /etc/rc.d/rc.espeakup stop
fi
if [ "$SPEECHDUP" = "y" ]; then
sh /etc/rc.d/rc.speechd-up stop
fi
modprobe speakup_$ARGUMENT 2>/dev/null
echo $ARGUMENT > /sys/accessibility/speakup/synth
if [ $? != 0 ]; then
echo "Unable to switch to the $ARGUMENT synthesizer."
echo "Something should be wrong."
exit 1
fi
printf "Should $ARGUMENT be also used at next boot? [Y/n] "
read ANSWER
if [ ! "$(to_lower $ANSWER)" = "n" ]; then
chmod 644 /etc/rc.d/rc.speechd-up
[ -f /etc/rc.d/rc.fenrir ] && chmod 644 /etc/rc.d/rc.fenrir
chmod 755 /etc/rc.d/rc.espeakup
echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
echo "hard=$ARGUMENT" >> /etc/speakup.conf
echo "Done."
fi
esac
More information about the Speakup
mailing list