data_dir_manipulation_lib.py
689 Bytes
import subprocess
def RunKaldiCommand(command, wait = True):
""" Runs commands frequently seen in Kaldi scripts. These are usually a
sequence of commands connected by pipes, so we use shell=True """
#logger.info("Running the command\n{0}".format(command))
p = subprocess.Popen(command, shell = True,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
if wait:
[stdout, stderr] = p.communicate()
if p.returncode is not 0:
raise Exception("There was an error while running the command {0}\n".format(command)+"-"*10+"\n"+stderr)
return stdout, stderr
else:
return p