Last active
February 16, 2019 11:55
-
-
Save korakot/8b941f55ce707f3c6f4dd4ae1e60b6ae to your computer and use it in GitHub Desktop.
thpronun wrapper for use in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!apt install libthai-dev help2man | |
!wget ftp://linux.thai.net/pub/thailinux/software/thpronun/thpronun-0.2.0.tar.xz | |
!tar xf thpronun-0.2.0.tar.xz | |
%cd thpronun-0.2.0 | |
!./configure --prefix=/usr | |
!make | |
!make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from ast import literal_eval | |
def thpronun(word, output='t', lattice=False): | |
cmd = ['thpronun', '-'+output] | |
if lattice: | |
cmd.append('-g') | |
cmd.append(word) | |
res = subprocess.check_output(cmd) | |
lines = res.decode().strip().split('\n') | |
if lattice: | |
return literal_eval(lines[1]) | |
else: | |
return lines[1:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment