Skip to content

Instantly share code, notes, and snippets.

@mandel59
Created March 25, 2012 04:31
Show Gist options
  • Save mandel59/2191366 to your computer and use it in GitHub Desktop.
Save mandel59/2191366 to your computer and use it in GitHub Desktop.
Open JTalkを使うためのシェルスクリプト
#!/bin/bash
VOICE_PATH=$HOME/works/MMDAgent_Example-1.1/Voice
if [ "x$VOICE" = "x" ] || ! [ -d "$VOICE" ] ; then
#VOICE=$HOME/works/hts_voice_nitech_jp_atr503_m001-1.04
VOICE="$VOICE_PATH"/mei_normal
fi
VOICES=( \
"$VOICE_PATH"/mei_normal \
"$VOICE_PATH"/mei_angry \
"$VOICE_PATH"/mei_bashful \
"$VOICE_PATH"/mei_happy \
"$VOICE_PATH"/mei_sad \
"$VOICE_PATH"/mei_normal \
"$VOICE_PATH"/mei_normal \
"$VOICE_PATH"/mei_normal \
"$VOICE_PATH"/mei_normal \
$HOME/works/hts_voice_nitech_jp_atr503_m001-1.04 )
if [ "x$DICT" = "x" ] || ! [ -d "$VOICE" ] ; then
DICT=$HOME/works/open_jtalk_dic_utf_8-1.05
fi
d=$(mktemp -d) || exit
trap "rm -rf -- '$d' ; exit" 1 2 3 15
k=
IFS_ORIG=$IFS
IFS=
while read FL ; do
if [ "x$FL" = "x" ] || echo $FL | grep "^#" > /dev/null ; then
continue
fi
if echo $FL | grep "^<[0-9]>$" > /dev/null ; then
VOICE=${VOICES[$(echo $FL | cut -c 2)]}
continue
fi
t=$(mktemp --tmpdir="$d" --suffix=.wav)
echo $FL | VOICE=$VOICE DICT=$DICT jtalk -ow "$t"
if [ "x$1" != "x" ] ; then
l=$k
k=$(mktemp --tmpdir="$d" --suffix=.flac)
if [ -f "$l" ] ; then
sox "$l" "$t" "$k" ; rm -f -- "$l" "$t"
else
sox "$t" "$k" ; rm -f -- "$t"
fi
else
play -q "$t" &
sleep $(soxi -D "$t")
fi
done
IFS=$IFS_ORIG
if [ "x$1" != "x" ] ; then
sox "$k" "$1"
fi
trap - 1 2 3 15
rm -rf -- "$d"
#!/bin/sh
if [ "x$VOICE" = "x" ] || ! [ -d "$VOICE" ] ; then
#VOICE=$HOME/works/hts_voice_nitech_jp_atr503_m001-1.04
VOICE=$HOME/works/MMDAgent_Example-1.1/Voice/mei_normal
fi
if [ "x$DICT" = "x" ] || ! [ -d "$VOICE" ] ; then
DICT=$HOME/works/open_jtalk_dic_utf_8-1.05
fi
open_jtalk -s 48000 -p 240 -a 0.55 \
-td $VOICE/tree-dur.inf -tm $VOICE/tree-mgc.inf \
-tf $VOICE/tree-lf0.inf -tl $VOICE/tree-lpf.inf \
-md $VOICE/dur.pdf -mm $VOICE/mgc.pdf \
-mf $VOICE/lf0.pdf -ml $VOICE/lpf.pdf \
-dm $VOICE/mgc.win1 -dm $VOICE/mgc.win2 \
-dm $VOICE/mgc.win3 -df $VOICE/lf0.win1 \
-df $VOICE/lf0.win2 -df $VOICE/lf0.win3 \
-dl $VOICE/lpf.win1 -em $VOICE/tree-gv-mgc.inf \
-ef $VOICE/tree-gv-lf0.inf -cm $VOICE/gv-mgc.pdf \
-cf $VOICE/gv-lf0.pdf -k $VOICE/gv-switch.inf \
-x $DICT "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment