0.3 Setting Things Up

The Setup

Finally, let's write some code! In this session, we will see how to import signals from the hard drive, how to display signals and how to write signals to the hard drive.

75KB
Open
Download this speech file

We begin with importing the essentials.

  • NumPy is for array handling,

  • iPython for i/o handling audio, and

  • Matplotlib to handle figures.

Let's also modify the formatting of the figures to make them neat!

import numpy as np
import IPython

from scipy import signal as sp
from scipy.io import wavfile

from matplotlib import pyplot as plt
from matplotlib import style
from matplotlib import rcParams

%matplotlib inline
plt.style.use(['seaborn-deep'])
plt.rcParams.update({
    "font.serif": ["cm"],
    "mathtext.fontset": "cm",
    "figure.figsize": (12,6),
    "font.size": 24})

Import a Speech File

Let's import a speech file and play the audio.

Fs, s = wavfile.read('speech.wav')
s = s / 32767.0
print('sampling rate: {}Hz'.format(Fs))
IPython.display.Audio(s, rate=Fs)

Last updated

Was this helpful?