Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active December 15, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kou1okada/5198421 to your computer and use it in GitHub Desktop.
Save kou1okada/5198421 to your computer and use it in GitHub Desktop.
easy use wrapper for open_jtalk
#!/usr/bin/env bash
# Copyright (c) 2013 Koichi OKADA. All rights reserved.
# This script is distributed under the MIT license.
# http://www.opensource.org/licenses/mit-license.php
SCRIPTNAME=${0##*/}
function usage ()
{
cat <<EOD
Usage: ${SCRIPTNAME} [options] [infile]
easy use wrapper for open_jtalk
options:
-o outfile (default: $OPT_o)
-c charactor (default: $OPT_c)
charactors:
`charactor | awk '{print " " $1;}'`
EOD
}
function charactor ()
{
if which cygcheck >& /dev/null; then
cygcheck -c -d | grep hts-voice | cut -d" " -f1 | xargs cygcheck -l | while read i; do echo ${i%/*}; done | sort | uniq | while read i; do echo ${i##*/} ${i}; done
else
cat <<-EOD
mei_angry /usr/share/hts-voice/MMDAgent_Example/Voice/mei_angry
mei_bashful /usr/share/hts-voice/MMDAgent_Example/Voice/mei_bashful
mei_happy /usr/share/hts-voice/MMDAgent_Example/Voice/mei_happy
mei_normal /usr/share/hts-voice/MMDAgent_Example/Voice/mei_normal
mei_sad /usr/share/hts-voice/MMDAgent_Example/Voice/mei_sad
nitech-jp-atr503-m001 /usr/share/hts-voice/nitech-jp-atr503-m001
EOD
fi
}
OPT_c=nitech-jp-atr503-m001
OPT_o=ezjtalk.$(date +%Y%m%d_%H%M%S).wav
DIC_DIR=/usr/dic
while [ $# -gt 0 ]; do
case "$1" in
--help|-h)
usage
exit
;;
-o)
shift
OPT_o="$1"
shift
;;
-c)
shift
OPT_c="$1"
shift
;;
-*)
echo -e "\e[31;1mError:\e[22m unknown parameter:\e[30m $1"
echo
usage
exit
;;
*)
ARGV+=("$1")
shift
;;
esac
done
if [ ${#ARGV[@]} -gt 1 ]; then
echo -e "\e[31;1mError:\e[22m too many arguments:\e[30m ${ARGV[@]}"
echo
usage
exit
fi
VOICE_DIR=$(charactor | awk 'BEGIN{char=ARGV[1];ARGV[1]=""} match($1, char){print $2}' "$OPT_c" | head -n1)
if [ "$VOICE_DIR" == "" ]; then
echo -e "\e[31;1mError:\e[22m unknown charactor:\e[30m $OPT_c"
echo
usage
exit
fi
open_jtalk \
-x "$DIC_DIR" \
-td ${VOICE_DIR}/tree-dur.inf \
-tm ${VOICE_DIR}/tree-mgc.inf \
-tf ${VOICE_DIR}/tree-lf0.inf \
-tl ${VOICE_DIR}/tree-lpf.inf \
-md ${VOICE_DIR}/dur.pdf \
-mm ${VOICE_DIR}/mgc.pdf \
-mf ${VOICE_DIR}/lf0.pdf \
-ml ${VOICE_DIR}/lpf.pdf \
-dm ${VOICE_DIR}/mgc.win1 \
-dm ${VOICE_DIR}/mgc.win2 \
-dm ${VOICE_DIR}/mgc.win3 \
-df ${VOICE_DIR}/lf0.win1 \
-df ${VOICE_DIR}/lf0.win2 \
-df ${VOICE_DIR}/lf0.win3 \
-dl ${VOICE_DIR}/lpf.win1 \
-ow "$OPT_o" \
-s 48000 \
-p 256 \
-a 0.55 \
-g 0 \
-b 0 \
-l \
-u 0.5 \
-em ${VOICE_DIR}/tree-gv-mgc.inf \
-ef ${VOICE_DIR}/tree-gv-lf0.inf \
-cm ${VOICE_DIR}/gv-mgc.pdf \
-cf ${VOICE_DIR}/gv-lf0.pdf \
-jm 1.0 \
-jf 0.8 \
-jl 1.0 \
-k ${VOICE_DIR}/gv-switch.inf \
-z 48000 \
"${ARGV[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment