正在初始化...命令' sox'返回非零退出状态2

时间:2014-06-16 19:00:29

标签: python audio exchange-server htk

我检查了类似的错误消息问题,但没有发现任何非常适合我的情况。我正在尝试使用HTK,Prosodylab-aligner和SoX将.wav文件与.lab文件对齐。

这是我的输入(使用Prosodylab-aligner):

./align.py /path/to/files

所有出现的都是这行代码:

Command 'sox' returned non-zero exit status 2

我查看了此代码的含义,显然这意味着缺少命令或关键字

我认为问题出在align.py文件中,但我不确定究竟在哪里。 这是引用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()

1 个答案:

答案 0 :(得分:0)

sox调用中的pids.append(Popen(...))命令行分解为cmd之类的变量,然后在运行之前将其打印出来。

这应该给你一个命令行,你可以重现问题,可能会看到更多的descpriptive错误信息,并可能通过调整参数缩小问题。

            # ...
            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
            # ...