On 4/18/25 22:18, Gregory Nowak via Dng wrote:
> On Fri, Apr 18, 2025 at 09:42:05PM -0400, fsmithred via Dng wrote:
>> set-default-card will just replace an existing /etc/asound.conf and restart
>> alsa-utils. There's no feedback sound. I guess I can put espeak commands
>> inside a script. I'll have to try that.
>
> If you can do that, it would help. If not, I can just run espeak-ng
> after set-card, though the more typing there is without feedback, the
> more likely it is that errors can be made. It wouldn't need to be
> fancy, a simple
>
> espeak-ng hello
>
> would do.
>
espeak or espeak-ng commands are not installed. That's easy to fix, but I
don't think it's necessary for this purpose. Also, it might get weird if
the system is reading stuff from the screen at the same time it's speaking
from a script.
If you run set-card first, you get sound. And then when you run
set-default-card, it announces that it's stopping and starting alsa.
If you don't get sound from the first command, you won't get it from the
second regardless of what's inside that script.
Some other thoughts:
The two scripts could be combined, but that's a little more complex.
Right now, set-card will let you use the name or number of the card for
/etc/default/espeakup, but set-default-card will only take a number for
asound.conf. I don't want to lose the ability to use a name, because you
might know you want to use a particular card, but you don't know what
number it will be. I've seen the devices come up in different order,
especially if there's a usb audio device involved.
I have a better set-card that you can run multiple times in a row. It
looks like this.
#!/usr/bin/env bash
# set-card
set -x
cardname="$1"
# check for an argument or exit
if [ -z "$cardname" ] ; then
echo " Usage:
"$0" <sound-card-id>"
exit 0
fi
# if argument is a number, check that the card number exists
if echo "$cardname" | grep [[:digit:]] ; then
if ! [ -e /proc/asound/card${cardname} ] ; then
echo "No such card"
exit 1
fi
fi
# if argument is a name, check that card name exists
if ! aplay -l | grep "$cardname" ; then
echo "No such card"
exit 1
fi
# change setting in the config file
sed -i '/ALSA_CARD=/d' /etc/default/espeakup
echo "ALSA_CARD=${cardname}" >> /etc/default/espeakup
/etc/init.d/espeakup restart
exit 0
fsmithred