import numpy as np from scipy.io import wavfile sample_rate = 8000 duration = 0.02 time = np.arange(int(sample_rate * duration)) / sample_rate channels = np.column_stack( ( 0.4 * np.sin(2 * np.pi * 440 * time), 0.4 * np.sin(2 * np.pi * 660 * time), ) ) source_pcm = np.round(channels * np.iinfo(np.int16).max).astype(np.int16)