3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

OpenJtalk で日本語の発話

Last updated at Posted at 2020-10-30

こちらと同じことを、Ubuntu 20.10 で確認しました。
OpenJTalk + python で日本語テキストを発話

私が確認した環境

$ uname -a
Linux iwata 5.8.0-26-generic #27-Ubuntu SMP Wed Oct 21 22:29:16 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 3.8.6
  1. ライブラリーのインストール
sudo apt install open-jtalk open-jtalk-mecab-naist-jdic hts-voice-nitech-jp-atr503-m001
  1. 音声ファイルのセットアップ
get https://sourceforge.net/projects/mmdagent/files/MMDAgent_Example/MMDAgent_Example-1.6/MMDAgent_Example-1.6.zip/download -O MMDAgent_Example-1.6.zip
unzip MMDAgent_Example-1.6.zip MMDAgent_Example-1.6/Voice/*
sudo cp -r MMDAgent_Example-1.6/Voice/mei/ /usr/share/hts-voice
  1. Python による再生
jtalk.py
#! /usr/bin/python
#
import subprocess
from datetime import datetime

def jtalk(tt):
    open_jtalk=['open_jtalk']
    mech=['-x','/var/lib/mecab/dic/open-jtalk/naist-jdic']
    htsvoice=['-m','/usr/share/hts-voice/mei/mei_normal.htsvoice']
    speed=['-r','1.0']
    outwav=['-ow','open_jtalk.wav']
    cmd=open_jtalk+mech+htsvoice+speed+outwav
    subprocess.run(cmd,input=tt.encode())
    aplay = ['aplay','-q','open_jtalk.wav']
    subprocess.run(aplay)

def say_datetime():
    d = datetime.now()
    text = '%s月%s日、%s時%s分%s秒' % (d.month, d.day, d.hour, d.minute, d.second)
    jtalk(text)

if __name__ == '__main__':
    say_datetime()
#

実行

./jtalk.py

時間を言い、open_jtalk.wav が作成されます。

wav ファイルの再生

$ aplay open_jtalk.wav 
再生中 WAVE 'open_jtalk.wav' : Signed 16 bit Little Endian, レート 48000 Hz, モノラル

サンプルのプログラム

ex01.py
#! /usr/bin/python
#
import jtalk

jtalk.jtalk('こんにちは')
#
ex02.py
#! /usr/bin/python
#
import jtalk

text_aa = 'あるひとがろばを一匹飼っていました。'
text_aa += 'このろばはそれまで長い間、休まずせっせと麦を水車小屋に運んできました。'

#
jtalk.jtalk(text_aa)
#
3
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?