Example #1
0

rawDataPath = os.path.join("..","rawData"); # directory where the audio fles reside

files = glob.glob(os.path.join(rawDataPath,"*.wav"))
names = [];
        
for name in files:
    fileName = os.path.basename(name).split(".")[0]
    names.append(fileName)


filt = (None,None,['17']) # 
audioFiles = pp.getKeys(names,filt);

(names,cDataset) = pp.readWAV(rawDataPath,audioFiles); # opens files and writes to a dictionary
       
#cDataset = loadSubset(data,audioFiles);
    

plt.figure(figsize=(50,20))

for ii in range(len(cDataset)):
    
    plt.subplot(len(cDataset)/2,2,ii+1)
    (Pxx,freqs,bins,im) = plt.specgram(cDataset[audioFiles[ii]][:,0],NFFT=2048,Fs=48000,noverlap=900,cmap=plt.cm.gist_heat)
    #plt.plot(cDataset[audioFiles[ii]][:,0]-cDataset[audioFiles[ii]][:,1],'b')
    #plt.ylim([3000,3800])
    plt.draw()

#plt.ion()
rawDataPath = os.path.join("..","rawData")

# extract all filenames
files = glob.glob(os.path.join(rawDataPath,"*.wav"))
names = []
for name in files:
    fileName = os.path.basename(name).split(".")[0]
    names.append(fileName)


# specify a specific file
filt = (None,None,['17']) #
audioFiles = pp.getKeys(names,filt);

# opens files and writes to a dictionary
(names,cDataset) = pp.readWAV(rawDataPath,audioFiles);

# cDataset = loadSubset(data,audioFiles);


def edges2fractures(ts, Fs=48000, edge_type='Sobel', smoothing=None):
    """
        edges2fractures predicts peaks locations based on edges
        in the signal spectrogram

        Inputs
        ------

        Fs: scalar
            the frequency of the signal
        edge_type: string
if __name__ == "__main__":

    # importing common packages
    import numpy as np
    from scipy import signal
    import matplotlib.pyplot as plt
    import os

    # importing local packages
    import preprocessing as pp

    # reading all the audio data into a dictionary
    audioPath = os.path.join(os.getcwd(), "..", "..", "rawAudio")

    filenames, audioDict = pp.readWAV(audioPath)
    filenames, audioDict = pp.readWAV(audioPath)

    # extracting the filenames of interest
    keys = pp.getKeys(filenames, (["B1"], None, ["15"]))

    # subsetting the data
    subset = pp.loadSubset(audioDict, keys)

    # Note: for now we design sync_envelope to work with two signals
    # However, there may be several time processing steps which could be applied to all of the signals at the same time: instead of two by two.
    # it is possible that even the cross-correlation can be spead up by doing it in ND

    # add test using a specific sine wave or something
    # add test for shifting the same signal
Example #4
0
rawDataPath = os.path.join("..", "rawData")
# directory where the audio fles reside

files = glob.glob(os.path.join(rawDataPath, "*.wav"))
names = []

for name in files:
    fileName = os.path.basename(name).split(".")[0]
    names.append(fileName)

filt = (None, None, ['17'])  #

audioFiles = pp.getKeys(names, filt)

(names, cDataset) = pp.readWAV(rawDataPath, audioFiles)
# opens files and writes to a dictionary

Nf = 24000
# Nyquist freqency in Hz
Fpass = [3200 / Nf, 3300 / Nf]
Fstop = [3100 / Nf, 3400 / Nf]

N, Wn = scipy.signal.ellipord(Fpass, Fstop, 1, 60, False)
b, a = scipy.signal.ellip(N, 1, 60, Wn, 'bandpass')
w, h = scipy.signal.freqs(b, a, np.logspace(-4, 4, 500))

#plt.figure(figsize=(50,20))
#plt.semilogx(w, 20 * np.log10(abs(h)))
#plt.title('Elliptical bandpass filter isolate warning siren')
#plt.xlabel('Frequency [Hz]')
Example #5
0
if __name__ == "__main__":

    # importing common packages
    import numpy as np
    from scipy import signal
    import matplotlib.pyplot as plt
    import os

    # importing local packages
    import preprocessing as pp

    # reading all the audio data into a dictionary
    audioPath = os.path.join(os.getcwd(), '..', '..', 'rawAudio')

    filenames, audioDict = pp.readWAV(audioPath)
    filenames, audioDict = pp.readWAV(audioPath)

    # extracting the filenames of interest
    keys = pp.getKeys(filenames, (['B1'], None, ['15']))

    # subsetting the data
    subset = pp.loadSubset(audioDict, keys)

    # Note: for now we design sync_envelope to work with two signals
    # However, there may be several time processing steps which could be applied to all of the signals at the same time: instead of two by two.
    # it is possible that even the cross-correlation can be spead up by doing it in ND

    # add test using a specific sine wave or something
    # add test for shifting the same signal