Blame view

egs/wsj/s5/steps/data/data_dir_manipulation_lib.py 689 Bytes
8dcb6dfcb   Yannick Estève   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  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
  {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}
  ".format(command)+"-"*10+"
  "+stderr)
          return stdout, stderr
      else:
          return p