Skip to content

Instantly share code, notes, and snippets.

@mickey-happygolucky
Created January 23, 2019 10:45
Show Gist options
  • Save mickey-happygolucky/a70db98e17b06ce65945edb2b8c9fc1a to your computer and use it in GitHub Desktop.
Save mickey-happygolucky/a70db98e17b06ce65945edb2b8c9fc1a to your computer and use it in GitHub Desktop.
open_jtalk python sample with yocto
# coding=utf-8
import os
import subprocess
def talk(s):
model = '/usr/share/Voice/mei/mei_happy.htsvoice'
dic = '/usr/share/dic'
wav = '/tmp/talk.wav'
txt = '/tmp/talk.txt'
with open(txt, mode='w') as f:
f.write(s)
command = 'open_jtalk -m %s -x %s -ow %s %s' % (model, dic, wav, txt)
subprocess.call(command.strip().split(' '))
os.remove(txt)
command = 'aplay %s' % wav
subprocess.call(command.strip().split(' '))
os.remove(wav)
if __name__ == '__main__':
talk('日本語をしゃべります')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment