凹みTips

C++、JavaScript、Unity、ガジェット等の Tips について雑多に書いています。

Open JTalk で MMDAgent のメイちゃんに喋らせてみた

はじめに

家電音声操作結果のフィードバックとして何か喋って欲しいなぁと思い調査していました。そこで Open JTalk を見つけたので色々とやってみることにしました。現在までの情報をまとめておきます。

環境

Open JTalkの導入

を参考に導入します。

sudo apt-add-repository ppa:openhri/ppa
sudo aptitude update
sudo aptitude install openhrivoice

([2012/02/22 0:57] 修正)
これで完了です。

何か喋らせてみる

404 Not Foundを参考にシェルスクリプトを書きます。

talk.sh
#!/bin/sh
VOICE=/usr/lib/hts-voice/nitech-jp-atr503-m001
echo $1 | open_jtalk \
-td $VOICE/tree-dur.inf \
-tf $VOICE/tree-lf0.inf \
-tm $VOICE/tree-mgc.inf \
-md $VOICE/dur.pdf \
-mf $VOICE/lf0.pdf \
-mm $VOICE/mgc.pdf \
-df $VOICE/lf0.win1 \
-df $VOICE/lf0.win2 \
-df $VOICE/lf0.win3 \
-dm $VOICE/mgc.win1 \
-dm $VOICE/mgc.win2 \
-dm $VOICE/mgc.win3 \
-ef $VOICE/tree-gv-lf0.inf \
-em $VOICE/tree-gv-mgc.inf \
-cf $VOICE/gv-lf0.pdf \
-cm $VOICE/gv-mgc.pdf \
-k  $VOICE/gv-switch.inf \
-x /usr/lib/open_jtalk/dic/utf-8 \
-ow out.wav \
-ot out.log

で、実行してみます。

sh talk.sh "電気をつけてみました"
結果

http://hecomi.com/hatena/out.wav
ホラー映画で出てきそうな声ですね…。

人間っぽくする

open_jtalk

を実行すると次のようにオプションの説明が出力されます。

open_jtalk - The Japanese TTS system "Open JTalk"

  usage:
       open_jtalk [ options ] [ infile ]
  options:                                                                   [  def][ min--max]
    -x dir         : dictionary directory                                    [  N/A]
    -td tree       : decision trees file for state duration                  [  N/A]
    -tm tree       : decision trees file for spectrum                        [  N/A]
    -tf tree       : decision trees file for Log F0                          [  N/A]
    -tl tree       : decision trees file for low-pass filter                 [  N/A]
    -md pdf        : model file for state duration                           [  N/A]
    -mm pdf        : model file for spectrum                                 [  N/A]
    -mf pdf        : model file for Log F0                                   [  N/A]
    -ml pdf        : model file for low-pass filter                          [  N/A]
    -dm win        : window files for calculation delta of spectrum          [  N/A]
    -df win        : window files for calculation delta of Log F0            [  N/A]
    -dl win        : window files for calculation delta of low-pass filter   [  N/A]
    -ow s          : filename of output wav audio (generated speech)         [  N/A]
    -ot s          : filename of output trace information                    [  N/A]
    -s  i          : sampling frequency                                      [16000][   1--48000]
    -p  i          : frame period (point)                                    [   80][   1--]
    -a  f          : all-pass constant                                       [ 0.42][ 0.0--1.0]
    -g  i          : gamma = -1 / i (if i=0 then gamma=0)                    [    0][   0-- ]
    -b  f          : postfiltering coefficient                               [  0.0][-0.8--0.8]
    -l             : regard input as log gain and output linear one (LSP)    [  N/A]
    -u  f          : voiced/unvoiced threshold                               [  0.5][ 0.0--1.0]
    -em tree       : decision tree file for GV of spectrum                   [  N/A]
    -ef tree       : decision tree file for GV of Log F0                     [  N/A]
    -el tree       : decision tree file for GV of low-pass filter            [  N/A]
    -cm pdf        : filename of GV for spectrum                             [  N/A]
    -cf pdf        : filename of GV for Log F0                               [  N/A]
    -cl pdf        : filename of GV for low-pass filter                      [  N/A]
    -jm f          : weight of GV for spectrum                               [  1.0][ 0.0--2.0]
    -jf f          : weight of GV for Log F0                                 [  1.0][ 0.0--2.0]
    -jl f          : weight of GV for low-pass filter                        [  1.0][ 0.0--2.0]
    -k  tree       : use GV switch                                           [  N/A]
    -z  i          : audio buffer size                                       [ 1600][   0--48000]
  infile:
    text file                                                                [stdin]
  note:
    option '-d' may be repeated to use multiple delta parameters.
    generated spectrum, log F0, and low-pass filter coefficient
    sequences are saved in natural endian, binary (float) format.

パラメタ調整をすれば声の質が変わりそうです。そこで rti さんに下記のように教えてもらいました。

なのでちょっとシェルスクリプトをいじってみます。

#!/bin/sh

VOICE=/usr/lib/hts-voice/nitech-jp-atr503-m001
echo $1 | open_jtalk \
-td $VOICE/tree-dur.inf \
-tf $VOICE/tree-lf0.inf \
-tm $VOICE/tree-mgc.inf \
-md $VOICE/dur.pdf \
-mf $VOICE/lf0.pdf \
-mm $VOICE/mgc.pdf \
-df $VOICE/lf0.win1 \
-df $VOICE/lf0.win2 \
-df $VOICE/lf0.win3 \
-dm $VOICE/mgc.win1 \
-dm $VOICE/mgc.win2 \
-dm $VOICE/mgc.win3 \
-ef $VOICE/tree-gv-lf0.inf \
-em $VOICE/tree-gv-mgc.inf \
-cf $VOICE/gv-lf0.pdf \
-cm $VOICE/gv-mgc.pdf \
-k  $VOICE/gv-switch.inf \
-x /usr/lib/open_jtalk/dic/utf-8 \
-s 48000 \
-p 240 \
-a 0.58 \
-u 0.0 \
-jm 0.7 \
-jf 0.5 \
-l \
-z 48000 \
-ow $2 \
-ot out.log

そして実行してみます。

sh talk.sh "電気をつけてみました" out2.wav

http://hecomi.com/hatena/out2.wav
おぉ、人間っぽくなりました!

メイちゃんに喋らせてみる

野太い男の声より女の人の声の方が良いでしょう!ということで MMDAgent(mmdagent.jp)のメイちゃんに喋ってもらうことにします。「MMDAgent "Sample Script" version 1.1 (August 3, 2011)」の「Binary Package」をダウンロードしてきます。解凍すると中に「Voice」というフォルダがあるので、この中に入っている「mei_*」フォルダを現在作業しているディレクトリにコピってきます。そして talk.sh を次のように変更します(VOICE=$3にしただけです)。

#!/bin/sh

VOICE=$3
echo $1 | open_jtalk \
-td $VOICE/tree-dur.inf \
-tf $VOICE/tree-lf0.inf \
-tm $VOICE/tree-mgc.inf \
-md $VOICE/dur.pdf \
-mf $VOICE/lf0.pdf \
-mm $VOICE/mgc.pdf \
-df $VOICE/lf0.win1 \
-df $VOICE/lf0.win2 \
-df $VOICE/lf0.win3 \
-dm $VOICE/mgc.win1 \
-dm $VOICE/mgc.win2 \
-dm $VOICE/mgc.win3 \
-ef $VOICE/tree-gv-lf0.inf \
-em $VOICE/tree-gv-mgc.inf \
-cf $VOICE/gv-lf0.pdf \
-cm $VOICE/gv-mgc.pdf \
-k  $VOICE/gv-switch.inf \
-x /usr/lib/open_jtalk/dic/utf-8 \
-s 48000 \
-p 240 \
-a 0.58 \
-u 0.0 \
-jm 0.7 \
-jf 0.5 \
-l \
-z 48000 \
-ow $2 \
-ot out.log

次のように実行します。

sh talk.sh "電気をつけてみました" out3.wav mei_normal

http://hecomi.com/hatena/out3.wav
しゃべったぁぁぁぁぁああ。サフィックスの「_normal」を「_angry」とか「_bashful」とか変えれば感情表現もできます。

sh talk.sh "電気をつけてみました" out4.wav mei_bashful

http://hecomi.com/hatena/out4.wav
なんかジッってノイズはいってる気もするけど…。

おまけ

パラメタ設定しないでメイちゃんに喋らせると次のような声になりました。
http://hecomi.com/hatena/out5.wav
メイちゃん…(´;ω;`)ブワッ

まとめ

これで何かしら喋ってくれる環境が出来ましたので、家電音声操作のフィードバックとして取り敢えずナニカ喋らせてみたいと思います。