{
"metadata": {
"name": "Audio Features I"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Embdedded player from: https://github.com/Carreau/posts\n",
"import StringIO\n",
"import base64\n",
"import struct\n",
"from IPython.core.display import HTML\n",
"\n",
"def wavPlayer(data, rate):\n",
" \"\"\" will display html 5 player for compatible browser\n",
" The browser need to know how to play wav through html5.\n",
" there is no autoplay to prevent file playing when the browser opens\n",
" Adapted from SciPy.io.\n",
" \"\"\"\n",
" \n",
" buffer = StringIO.StringIO()\n",
" buffer.write(b'RIFF')\n",
" buffer.write(b'\\x00\\x00\\x00\\x00')\n",
" buffer.write(b'WAVE')\n",
" buffer.write(b'fmt ')\n",
" if data.ndim == 1:\n",
" noc = 1\n",
" else:\n",
" noc = data.shape[1]\n",
" bits = data.dtype.itemsize * 8\n",
" sbytes = rate*(bits // 8)*noc\n",
" ba = noc * (bits // 8)\n",
" buffer.write(struct.pack('