Learn Before
Concept

Audio Creation

SciPy also allows us create audio, such as sine waves, into WAV files. In combination with NumPy, we can define the sample rate and frequency. This is an example of creating a 100Hz sine wave sampled at 44,100 Hz.

from scipy.io.wavfile import write import numpy as np samplerate = 44100; fs = 100 t = np.linspace(0., 1., samplerate) amplitude = np.iinfo(np.int16).max data = amplitude * np.sin(2. * np.pi * fs * t) write("example.wav", samplerate, data.astype(np.int16))

0

1

Updated 2021-07-07

Contributors are:

Who are from:

Tags

Python Programming Language

Data Science