<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Using Jupyter/IPython for Teaching
<p xmlns
Step1:  Plotting
Step2:  Spectrogram
Squared magnitude of the Short Time Fourier Transform (STFT)
$$|\text{STFT}{x[n]}(m, \omega)|^2 = \left| \sum_{n=-\infty}^\infty x[n]w[n-m] \text{e}^{-j \omega n}\right|^2$$
Step3:  Symbolic Math
<ASSISTANT_TASK:>
Python Code:
import soundfile as sf
sig, fs = sf.read('data/singing.wav')
Explanation: Using Jupyter/IPython for Teaching
<p xmlns:dct="http://purl.org/dc/terms/">
  <a rel="license"
     href="http://creativecommons.org/publicdomain/zero/1.0/">
    <img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" />
  </a>
</p>
This notebook is meant to be a slide show.
If it doesn't look like a slide show, you probably have to install RISE:
python3 -m pip install rise --user
python3 -m notebook.nbextensions install --python rise --user
python3 -m notebook.nbextensions enable --python rise --user
If it doesn't work, you might have to use python instead of python3.
After the installation (and after re-loading the Jupyter notebook), you will have a new item in the toolbar which allows you to start the presentation.
What is Jupyter?
formerly known as IPython ("interactive Python")
an interactive terminal and a browser-based notebook
https://jupyter.org/
can be used with different programming languages:
Julia (http://julialang.org/)
Python (https://www.python.org/)
R (http://www.r-project.org/)
and many others ...
What's so great about the Jupyter notebook?
mix of text, code and results
media
images, audio, video
anything a web browser can display
equations
One notebook, many uses
interactive local use
static online HTML pages on http://nbviewer.jupyter.org/
interactive online use at https://mybinder.org/
nbconvert
HTML
$\mathrm{\LaTeX}$ $\to$ PDF
.py files
...
slide shows!
HTML5 &lt;audio&gt; tag
<audio src="data/singing.wav" controls>Your browser does not support the audio element.</audio>
singing.wav by www.openairlib.net; CC BY-SA.
Loading Audio Data in Python
End of explanation
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(len(sig)) / fs
plt.plot(t, sig)
plt.xlabel('time / seconds')
plt.grid()
Explanation: Plotting
End of explanation
plt.specgram(sig, Fs=fs)
plt.ylabel('frequency / Hz')
plt.xlabel('time / seconds')
plt.ylim(0, 10000);
Explanation: Spectrogram
Squared magnitude of the Short Time Fourier Transform (STFT)
$$|\text{STFT}{x[n]}(m, \omega)|^2 = \left| \sum_{n=-\infty}^\infty x[n]w[n-m] \text{e}^{-j \omega n}\right|^2$$
End of explanation
%matplotlib inline
import sympy as sp
sp.init_printing()
t, sigma, omega = sp.symbols(('t', 'sigma', 'omega'))
sigma = -2
omega = 10
s = sigma + sp.I * omega
x = sp.exp(s * t)
x
sp.plotting.plot(sp.re(x),(t, 0, 2 * sp.pi), ylim=[-2, 2], ylabel='Re{$e^{st}$}')
sp.plotting.plot(sp.im(x),(t, 0, 2 * sp.pi), ylim=[-2, 2], ylabel='Im{$e^{st}$}');
Explanation: Symbolic Math
End of explanation
<END_TASK>