Ejemplo n.º 1
0
def f0Conversion(dataOut, outname):
    """ Convert the discrete F0 into continuous F0, if the data is lf0
    """
    fileDir           = os.path.dirname(outname)
    fileName          = os.path.basename(outname)
    fileBase, fileExt = os.path.splitext(fileName)

    if fileExt == '.qf0' or fileExt == '.lf0':
        # for F0
        f0Max, f0Min, f0Levels, f0Interpolated   = cfg.f0Info

        defaultOutput(dataOut, fileDir + os.path.sep + fileBase + '.qf0')
        
        dataOut, vuv = f0funcs.f0Conversion(dataOut, f0Max, f0Min, f0Levels, 'd2c', f0Interpolated)
        if f0Interpolated:
            vuvFile  = fileDir + os.path.sep + fileBase + '.vuv'
            if os.path.isfile(vuvFile):
                vuv  = funcs.read_raw_mat(vuvFile, 1)
                dataOut[vuv<0.5] = 0.0
            else:
                print "Can't find %s for interpolated F0" % (vuvFile)
        
        # if the extension is .qf0 (quantized F0)
        defaultOutput(vuv, fileDir + os.path.sep + fileBase + '.vuv')
        defaultOutput(dataOut, fileDir + os.path.sep + fileBase + '.lf0')

    else:
        # for other data
        defaultOutput(dataOut, outname)
Ejemplo n.º 2
0
def f0Conversion(dataOut, outname):
    """ Convert the discrete F0 into continuous F0, if the data is lf0
    """
    fileDir           = os.path.dirname(outname)
    fileName          = os.path.basename(outname)
    fileBase, fileExt = os.path.splitext(fileName)

    if fileExt == '.qf0' or fileExt == '.lf0':
        # for F0
        f0Max, f0Min, f0Levels, f0Interpolated   = cfg.f0Info

        defaultOutput(dataOut, fileDir + os.path.sep + fileBase + '.qf0')
        
        dataOut, vuv = f0funcs.f0Conversion(dataOut, f0Max, f0Min, f0Levels, 'd2c', f0Interpolated)
        if f0Interpolated:
            vuvFile  = fileDir + os.path.sep + fileBase + '.vuv'
            if os.path.isfile(vuvFile):
                vuv  = funcs.read_raw_mat(vuvFile, 1)
                dataOut[vuv<0.5] = 0.0
            else:
                print("Can't find %s for interpolated F0" % (vuvFile))
        
        # if the extension is .qf0 (quantized F0)
        defaultOutput(vuv, fileDir + os.path.sep + fileBase + '.vuv')
        defaultOutput(dataOut, fileDir + os.path.sep + fileBase + '.lf0')

    else:
        # for other data
        defaultOutput(dataOut, outname)
Ejemplo n.º 3
0
def generate(inFile1, inFile2, outfile):
    data1 = np.asarray(py_rw.read_raw_mat(inFile1, 1), dtype=np.int32)
    data2 = py_rw.read_raw_mat(inFile2, 1)
    temp, _ = discreteF0.f0Conversion(data2.copy(), F0Max, F0Min, F0Inter,
                                      'c2d', F0Conti)
    data3 = np.zeros(data1.shape)
    data3[data2[data1] > 0] = 1
    py_rw.write_raw_mat(data3, outfile)
Ejemplo n.º 4
0
def f0convert(f0File, qF0Output, vuvOutputFile, f0Zero, f0Max, f0Min, f0Inter, f0Conti, f0Type):
    if f0Type == 0:
        data  = py_rw.read_raw_mat(f0File, 1)
        idx   = data > 0
        data[idx] = 1127.0 * np.log(data[idx]/700.0 + 1)
    elif f0Type == 1:
        data  = py_rw.read_raw_lf0(f0File, 1)
        idx   = data > 0
    F0Idx = data>f0Zero
    dataClas, vuv = discreteF0.f0Conversion(data.copy(), f0Max, f0Min, f0Inter, 'c2d', f0Conti)
    dataClas[vuv<1] = 0.0
    py_rw.write_raw_mat(dataClas, qF0Output)
    py_rw.write_raw_mat(vuv, vuvOutputFile)
with open(fileScp, 'r') as filePtr:
    for idx, fileName in enumerate(filePtr):
        fileName = fileName.rstrip('\n')
        print idx, fileName,
        filePath = fileDir + os.path.sep + fileName + fileExt
        data = py_rw.read_raw_mat(filePath, fileDim)

        if fileDim > 1:
            temp = np.zeros([data.shape[0]])
            temp = data[:,0]
            data = temp

        frameSum = frameSum + data.shape[0]

        F0Idx         = data>10
        dataClas, vuv = discreteF0.f0Conversion(data, F0Max, F0Min, F0Inter, 'c2d', F0Conti)
        dataClas[vuv<1] = 0.0
        #dataClas = np.zeros([data.shape[0]])
        #if F0Conti:
        #    # Continous F0
        #    pass
        #    dataClas[F0Idx] = np.round((data[F0Idx] - F0Min)/(F0Max - F0Min) * (F0Inter - 1))
        #else:
        #    # Discontinuous F0, leave one dimension for unvoiced
        #    dataClas[F0Idx] = np.round((data[F0Idx] - F0Min)/(F0Max - F0Min) * (F0Inter - 2)) + 1
        
        tmpmax = np.max(data[F0Idx])
        tmpmin = np.min(data[F0Idx])
        tmpmax2 = np.max(dataClas[F0Idx])
        tmpmin2 = np.min(dataClas[F0Idx])