I confirmed the same thing on Ubuntu 20.10. Speak Japanese text with OpenJTalk + python
The environment I confirmed
$ 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
sudo apt install open-jtalk open-jtalk-mecab-naist-jdic hts-voice-nitech-jp-atr503-m001
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
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 month%s day,%s time%s minutes%s seconds' % (d.month, d.day, d.hour, d.minute, d.second)
jtalk(text)
if __name__ == '__main__':
say_datetime()
#
Run
./jtalk.py
Say the time and open_jtalk.wav will be created.
Play wav files
$ aplay open_jtalk.wav
Playing WAVE'open_jtalk.wav' : Signed 16 bit Little Endian,Rate 48000 Hz,monaural
Sample program
ex01.py
#! /usr/bin/python
#
import jtalk
jtalk.jtalk('Hello')
#
ex02.py
#! /usr/bin/python
#
import jtalk
text_aa = 'A person had a donkey.'
text_aa += 'For a long time, this donkey has been rushing to bring wheat to the watermill.'
#
jtalk.jtalk(text_aa)
#
Recommended Posts