LoginSignup
1
1

More than 5 years have passed since last update.

OpenJTalk利用してひたすら入力した文字を読み上げるプログラムをPythonで作成。

Posted at

即興で合成音声で会話をする事が出来たので組んでみました。
入力欄に「end」を入力すれば終了します。


## coding=utf-8
import sys
import subprocess

#jatalkの合成音をwavファイルで出力して、aplayで再生する。
def jtalk(t):
    open_jtalk=['open_jtalk']
    mech=['-x','/var/lib/mecab/dic/open-jtalk/naist-jdic']
    htsvoice=['-m','/usr/share/hts-voice/mei/mei_bashful.htsvoice']
    speed=['-r','1.0']
    outwav=['-ow','open_jtalk.wav']
    cmd=open_jtalk+mech+htsvoice+speed+outwav
    c = subprocess.Popen(cmd,stdin=subprocess.PIPE)
    c.stdin.write(t)
    c.stdin.close()
    c.wait()
    aplay = ['aplay','-q','open_jtalk.wav']
    wr = subprocess.Popen(aplay)

args = sys.argv

a = 0
while a < 1:
  input_line = raw_input('talk:')
  if input_line == "end": #endを入力すると終了する。
    a = 1
  else:
    jtalk(input_line)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1