Sample Post - Jupyter Notebook embedding
This post is for test purposes. It presents a sample jupyter notebook to test jupyter embedding in jekyll. The pipeline followed loads a wav file, plots it, calculates its fft transform and plots its FFT magnitude as well.
#import libraries
%matplotlib inline
import soundfile as sf
import librosa
import matplotlib.pyplot as plt
import numpy as np
#Load wav
filename = "./chainsaw-01.wav"
Sin, Sr = sf.read(filename)
#convert stereo to mono
Sin = np.mean(Sin, axis=1)
print(f"Signal array: \n{Sin}\n\nSignal Sampling Rate: {Sr}")
plt.plot(Sin)
plt.title("Signal")
plt.show()
Signal array:
[ 3.05175781e-05 -1.52587891e-05 0.00000000e+00 ... 3.05175781e-05
-1.52587891e-05 0.00000000e+00]
Signal Sampling Rate: 48000
N=1024
fft = librosa.stft(Sin, n_fft=N)
magnitude = np.abs(fft[:N//2])
plt.plot(magnitude)
plt.title("FFT magnitude")
plt.show()