summaryrefslogtreecommitdiff
path: root/client/g2p.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-06-08 20:39:35 -0700
committerschneefux <schneefux+commit@schneefux.xyz>2014-06-21 12:39:11 -0700
commit84a92e5327997815488276021e5498f7681ab2d7 (patch)
tree972b154650d9a4ae3bd0a77b1ace36d403457053 /client/g2p.py
parent1744368ac1889fe0767f04d55e8f928553c8db1c (diff)
downloadjasper-client-84a92e5327997815488276021e5498f7681ab2d7.tar.gz
jasper-client-84a92e5327997815488276021e5498f7681ab2d7.zip
Stop hardcoding /home/jasper and abstract out mic.say for multiplatform support
Diffstat (limited to 'client/g2p.py')
-rw-r--r--client/g2p.py11
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")