Created
October 9, 2018 18:12
-
-
Save chrisdonahue/e7a8e4e0945abb8f56939a886bca39c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "name": "nesmdb_pianoroll_example.ipynb", | |
| "version": "0.3.2", | |
| "provenance": [], | |
| "collapsed_sections": [] | |
| }, | |
| "kernelspec": { | |
| "name": "python2", | |
| "display_name": "Python 2" | |
| } | |
| }, | |
| "cells": [ | |
| { | |
| "metadata": { | |
| "id": "UI8F6BgI7U3S", | |
| "colab_type": "code", | |
| "colab": {} | |
| }, | |
| "cell_type": "code", | |
| "source": [ | |
| "!pip install nesmdb==0.1.8\n", | |
| "!wget http://deepyeti.ucsd.edu/cdonahue/nesmdb/nesmdb24_exprsco.tar.gz\n", | |
| "!tar xvfz nesmdb24_exprsco.tar.gz" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "id": "llaie-YM7gLE", | |
| "colab_type": "code", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 109 | |
| }, | |
| "outputId": "dd2da2bc-289f-4fe4-e30f-b4d4577a9511" | |
| }, | |
| "cell_type": "code", | |
| "source": [ | |
| "# Find files\n", | |
| "import glob\n", | |
| "exprsco_fps = glob.glob('nesmdb24_exprsco/train/*')\n", | |
| "print len(exprsco_fps)\n", | |
| "\n", | |
| "# Pick a random one\n", | |
| "import random\n", | |
| "import cPickle as pickle\n", | |
| "exprsco_fp = random.choice(exprsco_fps)\n", | |
| "print exprsco_fp\n", | |
| "with open(exprsco_fp, 'rb') as f:\n", | |
| " exprsco = pickle.load(f)\n", | |
| "\n", | |
| "# Preview the one we loaded\n", | |
| "from nesmdb.convert import exprsco_to_wav\n", | |
| "from IPython.display import display, Audio\n", | |
| "def preview_exprsco(exprsco):\n", | |
| " wav = exprsco_to_wav(exprsco)\n", | |
| " display(Audio(wav[:44100 * 10], rate=44100))\n", | |
| "\n", | |
| "preview_exprsco(exprsco)" | |
| ], | |
| "execution_count": 13, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": [ | |
| "4502\n", | |
| "nesmdb24_exprsco/train/335_TecmoCupSoccerGame_18_19AwardsCeremonyJPVer.exprsco.pkl\n" | |
| ], | |
| "name": "stdout" | |
| }, | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": [ | |
| "<IPython.lib.display.Audio object>" | |
| ], | |
| "text/html": [ | |
| "\n", | |
| " <audio controls=\"controls\" >\n", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment