diff options
Diffstat (limited to 'client/g2p.py')
| -rw-r--r-- | client/g2p.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/client/g2p.py b/client/g2p.py index 87e8b0d..276f681 100644 --- a/client/g2p.py +++ b/client/g2p.py @@ -10,7 +10,7 @@ PHONE_MATCH = re.compile(r'<s> (.*) </s>') FST_MODEL = None # Try to get fst_model from config -profile_path = os.path.join(os.path.dirname(__file__),'profile.yml') +profile_path = os.path.join(os.path.dirname(__file__), 'profile.yml') if os.path.exists(profile_path): with open(profile_path, 'r') as f: profile = yaml.safe_load(f) @@ -20,6 +20,7 @@ if os.path.exists(profile_path): if not FST_MODEL: FST_MODEL = os.environ['JASPER_HOME'] + "/phonetisaurus/g014b2b.fst" + def parseLine(line): return PHONE_MATCH.search(line).group(1) @@ -29,7 +30,8 @@ def parseOutput(output): def translateWord(word): - out = subprocess.check_output(['phonetisaurus-g2p', '--model=%s' % FST_MODEL, '--input=%s' % word]) + out = subprocess.check_output( + ['phonetisaurus-g2p', '--model=%s' % FST_MODEL, '--input=%s' % word]) return parseLine(out) @@ -47,7 +49,8 @@ def translateWords(words): def translateFile(input_filename, output_filename=None): - out = subprocess.check_output(['phonetisaurus-g2p', '--model=%s' % FST_MODEL, '--input=%s' % input_filename, '--words', '--isfile']) + out = subprocess.check_output( + ['phonetisaurus-g2p', '--model=%s' % FST_MODEL, '--input=%s' % input_filename, '--words', '--isfile']) out = parseOutput(out) if output_filename: |
