diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-07-11 09:38:42 -0700 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-07-11 09:38:42 -0700 |
| commit | 43eebc44166da07388a2e932d1234090fda957ec (patch) | |
| tree | d5cc1793a0b6269df71cce2b58ea099c60e4e455 /client/g2p.py | |
| parent | ea082f844a6748141aa61143421e4e9d0cc19bda (diff) | |
| parent | 8a5e5ed385a5c467260c2f1b20816a66cebfc1c6 (diff) | |
| download | jasper-client-43eebc44166da07388a2e932d1234090fda957ec.tar.gz jasper-client-43eebc44166da07388a2e932d1234090fda957ec.zip | |
Merge pull request #100 from astahlman/master
Platform independent audio output. Stop hardcoding /home/jasper.
Diffstat (limited to 'client/g2p.py')
| -rw-r--r-- | client/g2p.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/client/g2p.py b/client/g2p.py index 06fef14..6d72bfe 100644 --- a/client/g2p.py +++ b/client/g2p.py @@ -4,6 +4,7 @@ import re TEMP_FILENAME = "g2ptemp" PHONE_MATCH = re.compile(r'<s> (.*) </s>') +PHONETISAURUS_PATH = os.environ['JASPER_HOME'] + "/phonetisaurus" def parseLine(line): @@ -16,7 +17,7 @@ def parseOutput(output): def translateWord(word): out = subprocess.check_output(['phonetisaurus-g2p', '--model=%s' % - os.path.expanduser("~/phonetisaurus/g014b2b.fst"), '--input=%s' % word]) + PHONETISAURUS_PATH + "/g014b2b.fst", '--input=%s' % word]) return parseLine(out) @@ -34,8 +35,8 @@ def translateWords(words): def translateFile(input_filename, output_filename=None): - out = subprocess.check_output(['phonetisaurus-g2p', '--model=%s' % os.path.expanduser( - "~/phonetisaurus/g014b2b.fst"), '--input=%s' % input_filename, '--words', '--isfile']) + out = subprocess.check_output(['phonetisaurus-g2p', '--model=%s' % + PHONETISAURUS_PATH + "/g014b2b.fst", '--input=%s' % input_filename, '--words', '--isfile']) out = parseOutput(out) if output_filename: @@ -51,5 +52,5 @@ def translateFile(input_filename, output_filename=None): if __name__ == "__main__": - translateFile(os.path.expanduser("~/phonetisaurus/sentences.txt"), - os.path.expanduser("~/phonetisaurus/dictionary.dic")) + translateFile(PHONETISAURUS_PATH + "/phonetisaurus/sentences.txt", + PHONETISAURUS_PATH + "/phonetisaurus/dictionary.dic") |
