Re: espeakup: Voice change after Ctrl+F7 => Crtl+F2 if it is not a language

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10/03/2019 12:10, Samuel Thibault wrote:
> I guess you meant -V, not -v ?

Yes
 
> I am actually surprised that it's that way, what I see would be the
> converse: reinitialize_espeak() uses espeak_SetVoiceByName (i.e. fr-fr
> only would work).

However it behaves like I wrote
 
>> I have seen this commit:
>> https://github.com/williamh/espeakup/commit/ee099174d849e32bf7b555e458963d27f84c64b2
>> "Allow a voice to be selected by language name"
>> but do not know if/why this could be related to that. 
> 
> Because it brings two ways of setting the voice: either by language or
> by name.
> 
> I'd say synth_t's char *voice field should be replaced by a espeak_VOICE
> voice_select field, and make set_voice fill it before just always
> calling espeak_SetVoiceByProperties(), trying to use the "name" member
> before trying to use the "language" member. reinitialize_espeak()
> then just has to call espeak_SetVoiceByProperties on it instead of
> espeak_SetVoiceByName.
> 
> Could you have a look at doing that?

Only after the release of Slint64-14.2.1.2.

Meanwhile, I will inform users and tell them to either
run "service restart espeakup" when they are back to the tty
or set voice=<some language name> in /etc/espeakup.conf

This is still an inconvenience.

FYI I attach the script that runs at startup if executable
and /etc/espeakup.conf. You will see that I have borrowed some
code snippets to a Debian installer ;)

#!/bin/sh

if grep -q speakup /proc/cmdline; then
	exit
fi

# Create '/dev/(soft)synth' if not present
(cd /dev
if [ ! -c /dev/softsynth ]; then
	mknod softsynth c 10 26
fi
if [ ! -c /dev/synth ]; then
	mknod synth c 10 25
fi
)

# Load the software synthesizer
echo "soft" > /sys/accessibility/speakup/synth

sleep 1

# Permissions
chmod 666 /sys/accessibility/speakup/soft/*
echo 1 > /sys/accessibility/speakup/soft/direct

if [ "$LANG" = "" ]; then
. /etc/profile.d/lang.sh
fi

# Starts/stops/restart espeakup
set_voice () {
	lang=`echo $LANG | sed 's/_.*//'`
	country=`echo $LANG | sed 's/.*_//;s/\..*//;s/@.*//' | tr A-Z a-z`
	if [ "$lang" = gl ]; then
		# Not supported by espeak yet, but pt should be fine enough, better
		# than English anyway
		# Comment above from Debian. We don't propose gv in Slint yet, but
		# maybe later ?
		lang=pt
	fi
	
	if grep -qr "^language $lang-$country$" /usr/share/espeak-ng-data/lang; then
		VOICE="$lang-$country"
	elif grep -qr "^language $lang$" /usr/share/espeak-ng-data/lang; then
		VOICE="$lang"
	else
		VOICE=en
	fi
	echo $VOICE > /tmp/espeakup_default_voice
}
set_voice
DEFAULTVOICE=$(cat /tmp/espeakup_default_voice)
rm /tmp/espeakup_default_voice
espeakup_start() {
	[ "$LANG" = "" ] && . /etc/profile.d/lang.sh
	if [ -f /etc/espeakup.conf ]; then
		. /etc/espeakup.conf
		if [ ! "$rate" = "" ]; then
			echo $rate > /sys/accessibility/speakup/soft/rate
		else
			echo 2 > /sys/accessibility/speakup/soft/rate
		fi
		if [ ! "$vol" = "" ]; then
			echo $vol > /sys/accessibility/speakup/soft/vol
		else
			echo 4 > /sys/accessibility/speakup/soft/vol
		fi
		if [ ! "$pitch" = "" ]; then
			echo $pitch > /sys/accessibility/speakup/soft/pitch
		else
			echo 4 > /sys/accessibility/speakup/soft/pitch
		fi
		if [ "$voice" = "" ]; then
			voice=$DEFAULTVOICE
		fi
		if [ "$ALSA_CARD" = "" ]; then
			ALSA_CARD=0
		fi
	else
		voice=$DEFAULTVOICE
		echo 2 > /sys/accessibility/speakup/soft/rate
		echo 4 > /sys/accessibility/speakup/soft/vol
		echo 3 > /sys/accessibility/speakup/soft/pitch
		ALSA_CARD=0
	fi
	if [ ! "`ps -C espeakup --noheaders|wc -l`" = "0" ]; then
		echo "espeakup is already started."
		espeakup_status
		exit
	fi
	if [ -x /usr/bin/espeakup ]; then
		echo "Starting espeakup"
		ALSA_CARD=$ALSA_CARD /usr/bin/espeakup -V $voice
	else
		echo "/usr/bin/espeakup not found or non executable"
	fi
}

espeakup_stop() {
  NBPROC="`ps -C espeakup --noheaders|wc -l`"
  if [ ! "$NBPROC" = "0" ]; then
    sleep 1
    PID="`ps -C espeakup --noheaders -o pid`"
    kill -s 9 $PID
    # Restore the defaults
    echo 2 > /sys/accessibility/speakup/soft/rate
    echo 5 > /sys/accessibility/speakup/soft/vol
    echo 3 > /sys/accessibility/speakup/soft/pitch
  fi
}

espeakup_restart() {
    espeakup_stop
    sleep 2
    espeakup_start
}

espeakup_status() {
  NBPROC="`ps -C espeakup --noheaders|wc -l`"
  if [ "$NBPROC" = "0" ]; then
    echo "espeakup is not started" 
  elif [ "$NBPROC" = "1" ]; then
    echo "An espeakup daemon is running, PID: `ps -C espeakup --no-headers -o pid`"
  else
    ps -C espeakup -o pid,args
  fi
}

case "$1" in
    start)
	    espeakup_start;;
    stop)
		espeakup_stop;;
    restart)
		espeakup_restart;;
    status)
		espeakup_status;;
    *)
        echo "Usage: $0 {start|stop|restart|status}";;
esac

# Configuration file for espeakup

# To provide a value that differs from the default one, remove the first
# character '#' from the line and modify the value.
# Values outside the authorized range are silently ignored.

# Your modifications will be applied when espeakup will be restarted
# For that, save the modified file then either reboot or type as root:
# /etc/rc.d/rc.espeakup restart

# ***Voice
# The voice used should match the language in use. If a voice is set
# below, it will be used, else it will be chosen to match the value of
# the $LANG environment variable.
# To know available values type this command:
# spd-list -ls espeak-ng
# You may prefer to use one of the mbrola voices, that sound more
# natural. To list the installed ones type:
# spd-say -o espeak-ng-mbrola-generic -L
# The voice name is in the first column and preceded by 'mb-'
# For instance to use a French female voice you would write:
# voice=mb-fr2
#
voice=fr-fr

# ***Rate or speech speed
# minimum:0 maximum:9 
#rate=2

# ***Sound volume
#minimum:0 maximum:9
# If you set it to 0 you won't hear anything...
#vol=4

# ***Pitch adjustment: a bigger value gives a more acute sound
# 
#minimum:0 maximum:9
#pitch=3

# You only need to set the value of ALSA_CARD if you have several sound
# cards and want to specify which one espeakup should send the speech
# to, otherwise the default sound card will be used. The value should be
# a number in a range beginning with 0, like for instance ALSA_CARD=1 or
# the corresponding id, preferable as the sounds cards number can
# change, like ALSA_CARD=PCH. To know the number and id of your cards,#
# type: list-cards. To know more about your sound cards, type: aplay -l
# or aplay -L
# By default ALSA_CARD=0 (the first sound card), but if you used
# espeakup during installation, ALSA_CARD will be initially set to the
# id of the card you selected at the beginning of Slint installation
# 
ALSA_CARD=PCH
_______________________________________________
Speakup mailing list
Speakup@xxxxxxxxxxxxxxxxx
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup

[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]

  Powered by Linux