Posts about Signal Processing

Loading Audio Data

Goal

This post aims to introduce how to load wave audio data as an array.

Reference

Libraries

In [7]:
import pandas as pd
import numpy as np
from scipy.io import wavfile
import matplotlib.pyplot as plt
%matplotlib inline

Load a file as numpy

In [18]:
filename = '../data/sound00.wav'
fs, data = wavfile.read(filename)
data
Out[18]:
array([0, 0, 0, ..., 0, 0, 0], dtype=int16)

Visualize audio data

In [17]:
plt.figure(figsize=(16, 4))
plt.plot(data, lw=0.5, alpha=0.8);