January 2017
Beginner to intermediate
446 pages
8h 46m
English
Now that we know how audio signals work, let's see how we can generate one such signal. We can use the NumPy package to generate various audio signals. Since audio signals are mixtures of sinusoids, we can use this to generate an audio signal with some predefined parameters.
Create a new Python file and import the following packages:
import numpy as np import matplotlib.pyplot as plt from scipy.io.wavfile import write
Define the output audio filename:
# Output file where the audio will be saved output_file = 'generated_audio.wav'
Specify the audio parameters such as duration, sampling frequency, tone frequency, minimum value, and maximum value:
# Specify audio parameters duration = 4 # in seconds sampling_freq = 44100 # in ...
Read now
Unlock full access