summaryrefslogtreecommitdiff
path: root/client/g2p.py
diff options
context:
space:
mode:
Diffstat (limited to 'client/g2p.py')
-rw-r--r--client/g2p.py43
1 files changed, 21 insertions, 22 deletions
diff --git a/client/g2p.py b/client/g2p.py
index 741aa3f..b14ee98 100644
--- a/client/g2p.py
+++ b/client/g2p.py
@@ -43,28 +43,27 @@ class PhonetisaurusG2P(object):
cmd.extend(['--nbest=%d' % nbest])
cmd = [str(x) for x in cmd]
- with tempfile.SpooledTemporaryFile() as err_f:
- try:
- # FIXME: We can't just use subprocess.call and redirect stdout
- # and stderr, because it looks like Phonetisaurus can't open
- # an already opened file descriptor a second time. This is why
- # we have to use this somehow hacky subprocess.Popen approach.
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- stdoutdata, stderrdata = proc.communicate()
- returncode = proc.returncode
- if returncode != 0:
- logger.warning("Command '%s' return with exit status %d",
- ' '.join(cmd), returncode)
- except OSError:
- logger.error("Error occured while executing command '%s'",
- ' '.join(cmd), exc_info=True)
- stdoutdata, stderrdata = None, None
- if stderrdata is not None:
- for line in stderrdata.splitlines():
- message = line.strip()
- if message:
- logger.debug(message)
+ try:
+ # FIXME: We can't just use subprocess.call and redirect stdout
+ # and stderr, because it looks like Phonetisaurus can't open
+ # an already opened file descriptor a second time. This is why
+ # we have to use this somehow hacky subprocess.Popen approach.
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdoutdata, stderrdata = proc.communicate()
+ returncode = proc.returncode
+ if returncode != 0:
+ logger.warning("Command '%s' return with exit status %d",
+ ' '.join(cmd), returncode)
+ except OSError:
+ logger.error("Error occured while executing command '%s'",
+ ' '.join(cmd), exc_info=True)
+ stdoutdata, stderrdata = None, None
+ if stderrdata is not None:
+ for line in stderrdata.splitlines():
+ message = line.strip()
+ if message:
+ logger.debug(message)
result = {}
if stdoutdata is not None: