In [2]:
# imports libraries
import os
import sys
import glob
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
import math
import sklearn.decomposition as dcmp
import pyaudio
import csv
import IPython
%matplotlib inline
# Grabs the preprocessing and automatic_sync files
sys.path.append(os.path.join(os.pardir,'pythonCode'))
import preprocessing as pp
import automatic_sync as autoS
In [4]:
# now reads in the datafile from the raw data folder
rawDataPath = os.path.join(os.pardir,'rawData')
files = glob.glob(os.path.join(rawDataPath, 'IP*.wav'))
names = []
for name in files:
fileName = os.path.basename(name).split(".")[0]
names.append(fileName)
# Reads the .wav files from the list generted by getKeys
(names,rawDataset) = pp.readWAV(rawDataPath,names);
In [5]:
print(rawDataset[names[0]].shape)
Fs = 44100
In [7]:
this_range = range(6100000,6300000)
plt.figure(figsize=(12,4))
plt.subplot(2,1,1)
plt.specgram(rawDataset[names[0]][this_range], NFFT=1024, Fs=Fs, noverlap=512, cmap=plt.cm.gist_heat)
plt.xlabel('Time [sec]')
plt.ylabel('Freq [Hz]')
plt.subplot(2,1,2)
N = len(rawDataset[names[0]][this_range])
time = (1/Fs)*np.linspace(1,N,N)
plt.plot(time,rawDataset[names[0]][this_range])
plt.xlim(0,5)
plt.xlabel('Time [sec]')
plt.ylabel('Amplitude')
Out[7]:
In [6]:
this_range = range(7500000,7800000)
fig = plt.figure(figsize=(12,4))
plt.subplot(2,1,1)
plt.specgram(rawDataset[names[1]][this_range], NFFT=1024, Fs=Fs, noverlap=512, cmap=plt.cm.gist_heat)
plt.xlabel('Time [sec]')
plt.ylabel('Freq [Hz]')
plt.subplot(2,1,2)
N = len(rawDataset[names[1]][this_range])
time = (1/Fs)*np.linspace(1,N,N)
plt.plot(time,rawDataset[names[1]][this_range])
plt.xlim(0,7)
plt.xlabel('Time [sec]')
plt.ylabel('Amplitude')
Out[6]:
In [20]:
names[1]
Out[20]: