{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Spectrogram Reading\n",
"### ECE 590SIP, 2023 August 28"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Downloading and plotting waveforms\n",
"1. How to create and plot a spectrogram\n",
"1. Wideband and Narrowband spectrograms\n",
"1. Downloading examples of the English consonants\n",
"1. Manner of articulation: Glides, Nasals, Fricatives and Stops\n",
"1. The feature [sonorant]\n",
"1. The feature [continuant]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"import librosa # librosa can read & write sound files and spectrograms\n",
"import IPython # use this one to play waveforms in the Jupyter notebook\n",
"import numpy as np # We use this one to do numerical operations\n",
"import urllib, io # URLlib downloads things, io turns them into file-like objects\n",
"import matplotlib.pyplot as plt # We use this one to plot things\n",
"%matplotlib inline "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Plotting a waveform\n",
"The first thing we want to do is download two waveforms from the internet, plot them, play them, and then choose 1-second chunks to work with. We will explore many sources of audio in this course. Today, let's get our audio from Project Gutenberg. We'll download the first part of \"Pride and Prejudice\" (read by a female speaker), and the first part of \"White Fang\". We'll use urllib.request to download each file, then soundfile to load the audio and sampling frequency (fs), following the examples on the page https://pypi.python.org/pypi/PySoundFile/0.8.1\n",
"* Note: both of these files are OGG Vorbis audio format. Python soundfile works fine with OGG, WAV, and FLAC, but doesn't work with MP3. If you want to use MP3 files, you'll have to use some other more complicated Python library, and/or convert them before reading them in."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"# Download a segment from \"Pride and Prejudice\"\n",
"url = 'http://www.gutenberg.org/files/26301/ogg/26301-01.ogg'\n",
"long_audio, fs = librosa.load(io.BytesIO(request.urlopen(p_url).read()))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"