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')
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
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')
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 [ ]: