示例#1
0
def lpc_analysis_at_train(raw_data_one_batch,
                          order):  # already windowized by 512
    raw_data_one_batch = raw_data_one_batch[:, :, 0]
    how_many = raw_data_one_batch.shape[0]  # which is the batch size
    all_lpc_coeff_segments = np.empty((how_many, order))

    for i in range(how_many):
        preprocessed_frame = empha_filter(
            highpass_filter(raw_data_one_batch[i, :]))
        preprocessed_frame_listed = list(preprocessed_frame)
        # preprocessed_frame_listed = list(raw_data_one_batch[i, :])
        lpc_analysis = lpc(preprocessed_frame_listed, order)
        all_lpc_coeff_segments[i, :] = poly2lsf(
            ZFilter(np.array(lpc_analysis.numlist).tolist()).numlist)
    return all_lpc_coeff_segments  # after poly2lsf, the "1" is removed
示例#2
0
def lpc_analysis_at_test(raw_data, order):
    # all_lpc_res_segments = np.empty((how_many, 512))
    #
    # print(raw_data.shape, 'raw_data')
    raw_data = raw_data[:, :].flatten()

    ret = np.empty((len(
        range(0,
              len(raw_data) - frame_length * 2,
              frame_length * 2 - frame_length)), frame_length * 2))
    ind = 0
    for i in range(0,
                   len(raw_data) - frame_length * 2,
                   frame_length * 2 - frame_length):
        ret[ind, :] = raw_data[i:i + frame_length * 2] * 1
        ind += 1

    raw_data = ret
    # print(raw_data.shape, 'raw_data')

    how_many = raw_data.shape[0]
    all_lpc_coeff_segments = np.empty((how_many, order))

    for i in range(how_many):
        # no window
        # preprocessed_frame = (raw_data[i,:])
        # preprocessed_frame_listed = list(preprocessed_frame)
        # lpc_analysis = lpc(preprocessed_frame_listed, order)
        # all_lpc_coeff_segments[i,:] = poly2lsf(ZFilter(np.array(lpc_analysis.numlist).tolist()).numlist)
        # with window
        # preprocessed_frame = ((raw_data[i, :]))*np.hanning(512*2)
        preprocessed_frame = ((raw_data[i, :])) * np.append(
            np.append(np.hanning(256 * 2)[:256], np.array([1] * 512)),
            np.hanning(256 * 2)[256:])  # np.hanning(512*2)
        preprocessed_frame_listed = list(preprocessed_frame)
        lpc_analysis = lpc(preprocessed_frame_listed, order)
        all_lpc_coeff_segments[i, :] = poly2lsf(
            ZFilter(np.array(lpc_analysis.numlist).tolist()).numlist)
    return all_lpc_coeff_segments