{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EE16A: Homework 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 3: Finding Charges from Voltage Measurements" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 4: The Framingham Risk Score" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Tip: np.log works element-wise on an np.array" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 5: Filtering out the troll" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import wave as wv\n", "import scipy\n", "from scipy import io\n", "import scipy.io.wavfile\n", "from scipy.io.wavfile import read\n", "from IPython.display import Audio\n", "import warnings\n", "warnings.filterwarnings('ignore')\n", "sound_file_1 = 'm1.wav'\n", "sound_file_2 = 'm2.wav'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's listen to the recording by the first microphone (it can take some time to load the sound file)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "Audio(url='m1.wav', autoplay=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And this is the recording by the second microphone (it can take some time to load the sound file)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "Audio(url='m2.wav', autoplay=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We read the first recording to `corrupt1` and second recording to `corrupt2` variables." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "rate1,corrupt1 = scipy.io.wavfile.read('m1.wav')\n", "rate2,corrupt2 = scipy.io.wavfile.read('m2.wav')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Enter the gains to combine the two recordings to get the clean speech." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# enter the gains u to weight recording 1 and v to weight recording 2\n", "u =\n", "v =" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Weighted combination of the two recordings" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "s1 = u*corrupt1 + v*corrupt2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's listen to the resulting sound file (make sure your speaker's volume is not very high, the sound may be loud if things go wrong)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "Audio(data=s1, rate=rate1)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.10" } }, "nbformat": 4, "nbformat_minor": 0 }