1

I have checked similar error message questions but have not found anything that quite fits my situation. I am trying to time align a .wav file with a .lab file using HTK, Prosodylab-aligner, and SoX.

Here is my input (using Prosodylab-aligner):

./align.py /path/to/files

All that comes up is this line of code:

Command 'sox' returned non-zero exit status 2

I looked up what this code means and apparently it means there is a command or keyword missing

I believe that the problem is in the align.py file but I am not sure where exactly. Here is the area of the file that references SoX.

def _check_aud(self, wav_list, train=False):
    """
    Check audio files, mixing down to mono and downsampling if
    necessary. Writes copy_scp and the training or testing SCP files
    """
    copy_scp = open(self.copy_scp, 'a')
    check_scp = open(self.train_scp if train else self.test_scp, 'w')
    i = 0
    if self.has_sox:
        for wav in wav_list:
            head = os.path.splitext(os.path.split(wav)[1])[0]
            mfc = os.path.join(self.aud_dir, head + '.mfc')
            w = wave.open(wav, 'r')
            pids = []  # pids
            if (w.getframerate() != self.sr) or (w.getnchannels() > 1):
                new_wav = os.path.join(self.aud_dir, head + '.wav')
                pids.append(Popen(['sox', '-G', wav, '-b', '16',
                                   new_wav, 'remix', '-',
                                   'rate', str(self.sr),
                                   'dither', '-s'], stderr=PIPE))
                wav = new_wav
            for pid in pids:  # do a join
                retcode = pid.wait()
                if retcode != 0:
                    raise CalledProcessError(retcode, 'sox')
            print >> copy_scp, '"{0}" "{1}"'.format(wav, mfc)
            print >> check_scp, '"{0}"'.format(mfc)
            w.close()
    else:
        for wav in wav_list:
            head = os.path.splitext(wav)[0]
            mfc = os.path.join(self.aud_dir, head + '.mfc')
            w = wave.open(wav, 'r')
            if (w.getframerate() != self.sr) or (w.getnchannels() != 1):
                error('File {0} needs resampled but Sox not found ', w)
            print >> copy_scp, '"{0}" "{1}"'.format(wav, mfc)
            print >> check_scp, '"{0}"'.format(mfc)
            w.close()
    copy_scp.close()
    check_scp.close()
ford prefect
  • 7,096
  • 11
  • 56
  • 83
bhandwerk
  • 11
  • 3

1 Answers1

0

Factor out the sox command line in the pids.append(Popen(...)) call into a variable like cmd, and print that before running it.

That should give you a command line that you can reproduce the problem with, possibly see a more descpriptive error message, and maybe narrow the problem down by tweaking the arguments.

            # ...
            new_wav = os.path.join(self.aud_dir, head + '.wav')

            cmd = ['sox', '-G', wav, '-b', '16', 
                   new_wav, 'remix', '-', 'rate',
                   str(self.sr), 'dither', '-s']
            print "About to execute command:\n%s" % ' '.join(cmd)
            pids.append(Popen(cmd, stderr=PIPE))

            wav = new_wav
            # ...
Lukas Graf
  • 30,317
  • 8
  • 77
  • 92