def mk_sample_wav_file(dst, dur):
    if os.path.exists(dst):
        return
    wav = wave.open(dst, 'w')
    wav.setparams((2, 2, 44100, 0, 'NONE', 'un-compressed'))  # 2-ch
    # 44100 random samples between -1 and 1
    data = np.random.uniform(-1, 1, 44100 * dur)  # duration in seconds
    scaled = np.int16(data / np.max(np.abs(data)) * 32767)
    for i in scaled:
        v = struct.pack('h', i)  # short int, 2 bytes or 16 bits
        wav.writeframes(v)
        wav.writeframes(v)
    wav.close()
dataset/ETHPy150Open dthpham/butterflow/tests/test_avinfo.py/mk_sample_wav_file/original