In [4]:
import pandas as pd
import numpy as np

import wave

import scipy.io.wavfile
import math

from pylab import plot, show, title, xlabel, ylabel, subplot, savefig
from scipy import fft, arange, ifft
from numpy import sin, linspace, pi
from scipy.io.wavfile import read,write

%matplotlib inline

import seaborn as sns

In [14]:
rate, data = scipy.io.wavfile.read('http://sf.life/sounds/fog_horns/fog_horns_007.wav')


---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-14-de8dec5fa889> in <module>()
----> 1 rate, data = scipy.io.wavfile.read('http://sf.life/sounds/fog_horns/fog_horns_007.wav')

/Users/tgreen/anaconda/lib/python2.7/site-packages/scipy/io/wavfile.pyc in read(filename, mmap)
    231         mmap = False
    232     else:
--> 233         fid = open(filename, 'rb')
    234 
    235     try:

IOError: [Errno 2] No such file or directory: 'http://sf.life/sounds/fog_horns/fog_horns_007.wav'

In [11]:
url_path = 'sf.life/sounds/'
folder_path = 'fog_horns/fog_horns_'
wav_num = '007.wav'

x = pd.read_csv('http://sf.life/sounds/fog_horns/fog_horns_007.wav')
#sound_file = url_path + folder_path + wav_num

sound_file = x
rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
foghorn = df


---------------------------------------------------------------------------
CParserError                              Traceback (most recent call last)
<ipython-input-11-b46a90a685f3> in <module>()
      3 wav_num = '007.wav'
      4 
----> 5 x = pd.read_csv('http://sf.life/sounds/fog_horns/fog_horns_007.wav')
      6 #sound_file = url_path + folder_path + wav_num
      7 

/Users/tgreen/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
    644                     skip_blank_lines=skip_blank_lines)
    645 
--> 646         return _read(filepath_or_buffer, kwds)
    647 
    648     parser_f.__name__ = name

/Users/tgreen/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in _read(filepath_or_buffer, kwds)
    399         return parser
    400 
--> 401     data = parser.read()
    402     parser.close()
    403     return data

/Users/tgreen/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in read(self, nrows)
    937                 raise ValueError('skipfooter not supported for iteration')
    938 
--> 939         ret = self._engine.read(nrows)
    940 
    941         if self.options.get('as_recarray'):

/Users/tgreen/anaconda/lib/python2.7/site-packages/pandas/io/parsers.pyc in read(self, nrows)
   1506     def read(self, nrows=None):
   1507         try:
-> 1508             data = self._reader.read(nrows)
   1509         except StopIteration:
   1510             if self._first_chunk:

pandas/parser.pyx in pandas.parser.TextReader.read (pandas/parser.c:10415)()

pandas/parser.pyx in pandas.parser.TextReader._read_low_memory (pandas/parser.c:10691)()

pandas/parser.pyx in pandas.parser.TextReader._read_rows (pandas/parser.c:11437)()

pandas/parser.pyx in pandas.parser.TextReader._tokenize_rows (pandas/parser.c:11308)()

pandas/parser.pyx in pandas.parser.raise_parser_error (pandas/parser.c:27037)()

CParserError: Error tokenizing data. C error: Expected 5 fields in line 19, saw 6

In [26]:
## FOG HORN
folder_path = 'repository/fog_horns/fog_horns_'
file_name = '007.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
foghorn = df

## TROLLEY CAR
folder_path = 'repository/trolley_cars/trolley_cars_'
file_name = '007.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
trolley = df

## SKATEBOARDS
folder_path = 'repository/skateboards/skateboards_'
file_name = '009.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
skateboards = df

## BART
folder_path = 'repository/bart/bart_'
file_name = '006.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
bart = df

## SEALIONS 
folder_path = 'repository/sealions/sealions_'
file_name = '025.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
sealions = df

## CABLE CAR 
folder_path = 'repository/cable_cars/cable_cars_'
file_name = '022.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
cable_car = df

## CRISSY BEACH
folder_path = 'repository/crissy_beach/crissy_beach_'
file_name = '001.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
crissy_beach = df

## GOLDEN GATE BRIDGE
folder_path = 'repository/golden_gate_bridge/golden_gate_bridge_'
file_name = '003.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
golden_gate_bridge = df

## BART
folder_path = 'repository/bart/bart_'
file_name = '005.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
bart = df

## BIRDS OF TELEGRAPH HILL
folder_path = 'repository/birds_of_telegraph_hill/birds_of_telegraph_hill_'
file_name = '002.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
birds = df


## MUNI CAR
folder_path = 'repository/muni_cars/muni_cars_'
file_name = '001.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
muni_car = df

## SIRENS
folder_path = 'repository/sirens/sirens_'
file_name = '001.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
sirens = df

## TUNNELS
folder_path = 'repository/tunnels/tunnels_'
file_name = '002.wav'
sound_file = folder_path + file_name

rate, data = scipy.io.wavfile.read(sound_file)

df = pd.DataFrame(data)
#df = df[0]
tunnels = df

In [8]:
import matplotlib.pyplot as plt
fig,(ax) = plt.subplots(figsize=(24,12), ncols=1)

y=trolley[0]
lungime=len(y)
timp=len(y)/44100.
t=linspace(0,timp,len(y))

plt.xlabel('Time in Seconds', fontsize = 20)
plt.ylabel('Wave Length', fontsize = 20)
plt.tick_params(axis='both', which='major', labelsize=20)

plt.title("Trolley Car Crossing By at Fisherman's Wharf",y=1.02, fontsize = 24)

ax.plot(t,y)
fig.tight_layout()
fig.show()
fig.savefig('trolley.png')


C:\Users\tgreen\AppData\Local\Continuum\Anaconda2\lib\site-packages\matplotlib\figure.py:397: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure
  "matplotlib is currently using a non-GUI backend, "

In [5]:
fig,(ax) = plt.subplots(figsize=(24,12), ncols=1)

y=foghorn[0]
lungime=len(y)
timp=len(y)/44100.
t=linspace(0,timp,len(y))

plt.xlabel('Time in Seconds', fontsize = 20)
plt.ylabel('Wave Length', fontsize = 20)
plt.tick_params(axis='both', which='major', labelsize=20)

plt.title("Fog Horns at Golden Gate Bridge",y=1.02, fontsize = 24)

ax.plot(t,y)
fig.tight_layout()
fig.show()
fig.savefig('foghorn.png')



In [6]:
#import IPython
#IPython.display.Audio("fog_horns_007.wav")

In [9]:
fig,(ax) = plt.subplots(figsize=(24,12), ncols=1)

y=golden_gate_bridge[0]
lungime=len(y)
timp=len(y)/44100.
t=linspace(0,timp,len(y))

plt.xlabel('Time in Seconds', fontsize = 20)
plt.ylabel('Wave Length', fontsize = 20)
plt.tick_params(axis='both', which='major', labelsize=20)

plt.title("Traffic at Golden Gate Bridge",y=1.02, fontsize = 24)

ax.plot(t,y)
fig.tight_layout()
fig.show()
fig.savefig('golden_gate_bridge_traffic.png')



In [11]:
fig,(ax) = plt.subplots(figsize=(24,12), ncols=1)

y=bart[0]
lungime=len(y)
timp=len(y)/44100.
t=linspace(0,timp,len(y))

plt.xlabel('Time in Seconds', fontsize = 20)
plt.ylabel('Wave Length', fontsize = 20)
plt.tick_params(axis='both', which='major', labelsize=20)

plt.title("Montgomery Bart Station",y=1.02, fontsize = 24)

ax.plot(t,y)
fig.tight_layout()
fig.show()
fig.savefig('bart_station.png')



In [13]:
fig,(ax) = plt.subplots(figsize=(24,12), ncols=1)

y=birds[0]
lungime=len(y)
timp=len(y)/44100.
t=linspace(0,timp,len(y))

plt.xlabel('Time in Seconds', fontsize = 20)
plt.ylabel('Wave Length', fontsize = 20)
plt.tick_params(axis='both', which='major', labelsize=20)

plt.title("Birds of Telegraph Hill",y=1.02, fontsize = 24)

ax.plot(t,y)
fig.tight_layout()
fig.show()
fig.savefig('birds_of_telegraph_hill.png')



In [21]:
fig,(ax) = plt.subplots(figsize=(24,12), ncols=1)

y=muni_car[0]
lungime=len(y)
timp=len(y)/44100.
t=linspace(0,timp,len(y))

plt.xlabel('Time in Seconds', fontsize = 20)
plt.ylabel('Wave Length', fontsize = 20)
plt.tick_params(axis='both', which='major', labelsize=20)

plt.title("Montgomery Station - Muni Cars",y=1.02, fontsize = 24)

ax.plot(t,y)
fig.tight_layout()
fig.show()
fig.savefig('muni_car.png')



In [25]:
fig,(ax) = plt.subplots(figsize=(24,12), ncols=1)

y=sirens[0]
lungime=len(y)
timp=len(y)/44100.
t=linspace(0,timp,len(y))

plt.xlabel('Time in Seconds', fontsize = 20)
plt.ylabel('Wave Length', fontsize = 20)
plt.tick_params(axis='both', which='major', labelsize=20)

plt.title("Fire Truck at Embarcadero",y=1.02, fontsize = 24)

ax.plot(t,y)
fig.tight_layout()
fig.show()
fig.savefig('firetruck.png')



In [31]:
#colors = ('b', 'g', 'r', 'c', 'm', 'y', 'k')
fig,(ax) = plt.subplots(figsize=(24,12), ncols=1)

y=tunnels[0]
lungime=len(y)
timp=len(y)/44100.
t=linspace(0,timp,len(y))

plt.xlabel('Time in Seconds', fontsize = 20)
plt.ylabel('Wave Length', fontsize = 20)
plt.tick_params(axis='both', which='major', labelsize=20)

plt.title("Walking in Tunnel by Chinatown",y=1.02, fontsize = 24)

ax.plot(t,y, 'm')
fig.tight_layout()
fig.show()
fig.savefig('tunnel.png')



In [33]:
#print plt.style.available

#http://seaborn.pydata.org/tutorial/color_palettes.html

In [ ]: