Merge to local branch
master
Daniel Dylewsky 2022-01-24 12:07:59 -05:00
commit 1310f879b4
2 changed files with 109 additions and 1 deletions

View File

@ -51,7 +51,7 @@
"# x = regress(b,A)\n",
"\n",
"# Alternative 2:\n",
"x = np.linalg.pinv(A)*b"
"x = np.linalg.pinv(A)@b"
]
},
{

View File

@ -0,0 +1,108 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "5d998359",
"metadata": {},
"outputs": [],
"source": [
"import scipy\n",
"import scipy.io\n",
"import IPython.display\n",
"import numpy as np\n",
"import librosa\n",
"\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1f7443a8",
"metadata": {},
"outputs": [],
"source": [
"#Example to load mat file (first 40 seconds)\n",
"#file = scipy.io.loadmat('../DATA/beethoven_40sec.mat')\n",
"#sound = file[\"y\"][0] # data\n",
"#T = int(file[\"T\"][0][0]) # length in seconds\n",
"#FS = int(file[\"FS\"][0][0]) #sample frequency\n",
"#samples = T*FS\n",
"#t = np.arange(samples)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db4ff4da",
"metadata": {},
"outputs": [],
"source": [
"#original mp3 file\n",
"FS = 24000\n",
"y, sr = librosa.load('../DATA/beethoven.mp3', sr=FS)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "510e4bd3",
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(20,5))\n",
"plt.plot(y)\n",
"\n",
"#for \"mat\" file use command\n",
"#plt.plot(t, sound)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "697e8139",
"metadata": {},
"outputs": [],
"source": [
"IPython.display.Audio(y, rate=FS)\n",
"\n",
"#For mat file use command \n",
"#IPython.display.Audio(sound, rate=FS)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "72d27077",
"metadata": {},
"outputs": [],
"source": [
"plt.rcParams[\"figure.figsize\"] = (20,5)\n",
"plt.specgram(y, NFFT=8192, Fs=FS, noverlap=2048)\n",
"plt.colorbar()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}