Re: Talsyntes/Festival/Scaletempo/Ubuntu-AMD64
Postat: 13 okt 2008, 11:28
Jag ser inget fel i ~/.talsynes/.
Nu har jag lagt in lite kod så att den visar exakt vilket kommando den kör vid själva uppläsningen, så att vi sedan kan testa det kommandot löst:
Nu har jag lagt in lite kod så att den visar exakt vilket kommando den kör vid själva uppläsningen, så att vi sedan kan testa det kommandot löst:
Kod: Markera allt
#!/bin/sh
# r3-test
case "$-" in *i*) return ;; esac
export LC_ALL=C
exec 2>&-
APP="Talsyntes"
DIR=~/".talsyntes"
SCRIPT="$DIR/talsyntes.sh"
mkdir -p "$DIR/data" "$DIR/voices"
test "x$SCRIPT" != "x$0" &&
cp -f "$0" "$SCRIPT" 2>&- &&
exec "$SCRIPT" "$@"
XDIALOG="Xdialog --wmclass '$APP' --cancel-label Avbryt --no-tags --stdout"
find -L "$DIR" -maxdepth 1 -name voice -type l -exec rm {} \;
test -h "$DIR/voice" || test "$1" = install || set voice
ls "$DIR"/voices/[a-z][a-z][1-9]:* >/dev/null 2>&- &&
test -x "$SCRIPT" &&
test -x "$DIR/mbrola" ||
set install
cd "$DIR"
case "$1" in
stop)
pkill -P $(pgrep -d, "${SCRIPT##*/}") mplayer
;;
pause)
find "$DIR" -name mplayer.\*.fifo -type p -exec sh -c 'echo pause >{}' \;
;;
start)
"$SCRIPT" stop
find "$DIR" -name mplayer.\*.fifo -type p -exec rm -f {} \;
FIFO="$DIR/mplayer.$$.fifo"
trap 'rm -f "$FIFO"' EXIT
test -p "$FIFO" || mkfifo "$FIFO"
if voice=$(ls voices/"$2":* 2>&-)
then shift
else voice="$(readlink voice)"
fi
voice="${voice#voices/}"
speed="$2"
freq="$3"
volume="$4"
rate="$5"
test -z "$speed" && test -f speed &&
speed=$(awk '{printf("%f",exp(0.01*log(1/5)*$1))}' <speed)
test -z "$freq" && test -f freq &&
freq=$(awk '{printf("%f",exp(-0.01*log(1/5)*$1))}' <freq)
test -z "$volume" && test -f volume &&
volume=$(awk '{printf("%f",exp(-0.01*log(1/5)*$1))}' <volume)
test -z "$rate" && test -f rate &&
rate=$(awk '{printf("%f",16000*exp(-0.01*log(1/3)*$1))}' <rate)
echo xclip -o \|
echo espeak -v mb-"${voice%:*}" \|
echo "$DIR/mbrola" -e \
-t "${speed:-1}" \
-f "${freq:-1}" \
-v "${volume:-1}" \
-l "${rate:-16000}" \
"$DIR/voices/$voice" - -.wav \|
echo mplayer -input file="$FIFO" -really-quiet -demuxer audio -
xclip -o |
espeak -v mb-"${voice%:*}" |
"$DIR/mbrola" -e \
-t "${speed:-1}" \
-f "${freq:-1}" \
-v "${volume:-1}" \
-l "${rate:-16000}" \
"$DIR/voices/$voice" - -.wav |
mplayer -input file="$FIFO" -really-quiet -demuxer audio -
;;
reset)
case "$2" in
'') rm -f speed freq volume rate ;;
speed|freq|volume|rate) rm -f "$2" ;;
esac
;;
adjust)
case "$2" in
'')
test -f speed && speed=$(cat speed) || speed=0
test -f freq && freq=$(cat freq) || freq=0
test -f rate && rate=$(cat rate) || rate=0
set -- $(
$XDIALOG --title "$APP" --separator " " \
--3rangesbox "Röstparametrar" 22 60 \
"Uppläsningshastighet" -100 100 "$speed" \
"Röstläge" -100 100 "$freq" \
"Rösttäthet" -100 100 "$rate"
)
if test $# -eq 3
then
echo "$1" >speed
echo "$2" >freq
echo "$3" >rate
fi
exit
;;
speed) TITLE="Uppläsningshastighet" ;;
freq) TITLE="Röstläge" ;;
volume) TITLE="Uppläsningsvolym" ;;
rate) TITLE="Rösttäthet" ;;
*) exit ;;
esac
test -f "$2" && value=$(cat "$2") || value=0
case "$3" in
'')
value=$(
$XDIALOG --title "$APP" --rangebox "$TITLE" 10 60 -100 100 "$value"
)
test -n "$value" &&
echo "$value" >"$2"
;;
*)
echo "$3" |
awk -vvalue="$value" '{
if($1) value+=$1
else value=0
if(value>100) value=100
if(value<-100) value=-100
print(value)
}' >"$2"
;;
esac
;;
voice)
case "$2" in
'')
voice=$(
eval $XDIALOG --title "'$APP'" --no-close --no-cancel \
--radiolist "'Välj röst'" 20 60 0 $(
ls voices/[a-z][a-z][1-9]:* 2>&- |
while read voice
do test "x$voice" = "x$(readlink voice)" &&
radiobox=on ||
radiobox=off
printf "%s " "'$voice'" "'${voice#voices/}'" "$radiobox"
done
)
)
;;
*)
voice=$(ls "voices/$2":* 2>&-)
;;
esac
test -n "$voice" &&
ln -sf "$voice" voice
;;
install)
URL="http://tcts.fpms.ac.be/synthesis/mbrola"
TMP=$(mktemp)
trap 'rm -f "$TMP"' EXIT
wget -qO- "$URL"/mbrcopybin.html |
sed -n '
s|.*"\(bin/[^"]*.zip\)"[^>]*>[^<]*LINUX i386.*|\1 (0.3Mb)|p
s|.*"\(dba/[^/]*/[^"]*\)"[^>]*>\([^:]*:\s*[^<]*\).*|\1\t\2|p
' >"$TMP"
cd "$DIR"
voices=$(
cd /usr/share/espeak-data/voices/mb &&
echo mb-[a-z][a-z][1-9] |
sed 's/mb-//g;s/\(.\)\s\(.\)/\1|\2/g'
)
voices=$(
eval $XDIALOG --title "'$APP: Installation'" --separator "'|'" \
--checklist "'Välj språk'" 20 60 0 $(
grep -E "/($voices)/" <"$TMP" |
while read file voice
do case "$voice" in
sw*|us*|en*) checkbox=on ;;
*) checkbox=off ;;
esac
printf "%s " "${voice%:*}" "'$voice'" "$checkbox"
done
)
)
test -z "$voices" && exit
rm -f voices/[a-z][a-z][1-9]:* 2>&-
cd data
grep -E "(^bin|/$voices/)" <"$TMP" |
awk '{
size[NR]=size[NR-1]+substr($NF,2,length($NF)-4)
$NF=""
voice[NR]=$0
} END {
for(i=1; i<=NR; i++) {
print(100*size[i]/size[NR],voice[i])
}
}' |
while read progress file voice
do test -f "${file##*/}" ||
wget -q "$URL/$file" 2>&1
if test -z "$voice"
then
unzip -p "${file##*/}" mbrola-linux-i386 >"$DIR"/mbrola
chmod +x "$DIR"/mbrola
else
unzip -p "${file##*/}" "${voice%%:*}" >"$DIR/voices/$voice" 2>&- ||
unzip -p "${file##*/}" "${voice%%:*}/${voice%%:*}" \
>"$DIR/voices/$voice"
fi
echo $progress
done |
$XDIALOG --title "$APP: Installation" \
--no-close --gauge "Hämtar Röster..." 10 60
bind_key() {
case "$1" in
metacity)
KEY="/apps/metacity/global_keybindings"
CMD="/apps/metacity/keybinding_commands"
PREFIX="run_command_"
SUFFIX=""
;;
compiz)
KEY="/apps/compiz/general/allscreens/options"
CMD="/apps/compiz/general/allscreens/options"
PREFIX="run_command"
SUFFIX="_key"
;;
esac
gconftool-2 -a "$KEY" |
awk '$1~/^'"$PREFIX"'[0-9]+'"$SUFFIX"'$/ && $3~/^'"$2"'$/{print($1)}' |
while read binding
do gconftool-2 -u "$KEY/$binding"
done
ID=$(
gconftool-2 -a "$KEY" |
sed -n "s/^\s*$PREFIX\([0-9]\+\)$SUFFIX\s*=\s*/\1\t/p" |
sort -n |
awk '{if($1-prev>1)exit;prev=$1}END{print(prev+1)}'
)
gconftool-2 \
-s -t str "$KEY/$PREFIX${ID:-1}$SUFFIX" "$2" \
-s -t str "$CMD/${PREFIX#run_}${ID:-1}" "$3"
}
for wm in metacity compiz
do bind_key "$wm" "F1" "$SCRIPT stop"
bind_key "$wm" "F2" "$SCRIPT pause"
bind_key "$wm" "F3" "$SCRIPT start"
bind_key "$wm" "F4" "$SCRIPT start 0.5"
bind_key "$wm" "F5" "$SCRIPT start sw1 0.5"
bind_key "$wm" "F6" "$SCRIPT speed 0"
bind_key "$wm" "F7" "$SCRIPT speed -10"
bind_key "$wm" "F8" "$SCRIPT speed +10"
bind_key "$wm" "F9" "$SCRIPT adjust"
bind_key "$wm" "F10" "$SCRIPT voice"
bind_key "$wm" "F11" "$SCRIPT voice sw1"
bind_key "$wm" "F12" "$SCRIPT voice en1"
done
$XDIALOG --title "$APP" --msgbox "$APP installerad" 10 60
exec "$SCRIPT" voice
;;
speed|freq|volume|rate) exec "$SCRIPT" adjust "$@" ;;
*) exec "$SCRIPT" start "$@" ;;
esac
Kod: Markera allt
~/bin/talsyntes.sh start