Example #1
0
def test_depth_convert():
    y = paddleaudio.depth_convert(x, 'int16')
    assert len(y) == len(x)
    assert y.dtype == 'int16'
    assert np.max(y) <= 32767
    assert np.min(y) >= -32768
    assert np.std(y) > EPS

    y = paddleaudio.depth_convert(x, 'int8')
    assert len(y) == len(x)
    assert y.dtype == 'int8'
    assert np.max(y) <= 127
    assert np.min(y) >= -128
    assert np.std(y) > EPS
Example #2
0
dst_folder = args.output_folder
print(f'{len(h5_files)} h5 files listed')
for f in h5_files:
    print(f'processing {f}')
    dst_file = os.path.join(dst_folder, f.split('/')[-1])
    print(f'target file {dst_file}')
    if args.skip_existed != 0 and os.path.exists(dst_file):
        print(f'skipped file {f}')
        continue
    assert not os.path.exists(dst_file), f'target file {dst_file} existed'
    src_h5 = h5py.File(f)
    dst_h5 = h5py.File(dst_file, "w")
    for key in tqdm.tqdm(src_h5.keys()):
        s = src_h5[key][:]
        s = pa.depth_convert(s, 'float32')
        # s = pa.resample(s,32000,args.sample_rate)
        x = pa.features.mel_spect(s,
                                  sample_rate=args.sample_rate,
                                  window_size=args.window_size,
                                  hop_length=args.hop_length,
                                  mel_bins=args.mel_bins,
                                  fmin=args.fmin,
                                  fmax=args.fmax,
                                  window='hann',
                                  center=True,
                                  pad_mode='reflect',
                                  ref=1.0,
                                  amin=1e-10,
                                  top_db=None)
        #         figure(figsize=(8,8))