crossValidationTemplate.py
def spectral_features(filelist):
    """
    Given a list of files, retrieve them, analyse the first 100mS of each file and return
    a feature table.
    """
    number_of_files = len(filelist)
    number_of_features = 5
    features = np.zeros([number_of_files, number_of_features])
    sample_rate = 44100

    for file_index, url in enumerate(filelist):
        print url
        urllib.urlretrieve(url, filename='/tmp/localfile.wav')
        audio = MonoLoader(filename = '/tmp/localfile.wav', sampleRate = sample_rate)()
        zcr = ZeroCrossingRate()
        hamming_window = Windowing(type = 'hamming') # we need to window the frame to avoid FFT artifacts.
        spectrum = Spectrum()
        central_moments = CentralMoments()
        distributionshape = DistributionShape()
        spectral_centroid = Centroid()

        frame_size = int(round(0.100 * sample_rate))   # 100ms
        # Only do the first frame for now.
        # TODO we should generate values for the entire file, probably by averaging the features.
        current_frame = audio[0 : frame_size]
        features[file_index, 0] = zcr(current_frame)
        spectral_magnitude = spectrum(hamming_window(current_frame))
        centroid = spectral_centroid(spectral_magnitude)
        spectral_moments = distributionshape(central_moments(spectral_magnitude))
        features[file_index, 1] = centroid
        features[file_index, 2:5] = spectral_moments
    return features

    Given a list of files, retrieve them, analyse the first 100mS of each file and return
    a feature table.
    
Given a list of files, retrieve them, analyse the first 100mS of each file and return
a feature table.
Given a list of files retrieve them analyse the first 100mS of each file and return a feature table .
def spectral_features(filelist):
    number_of_files = len(filelist)
    number_of_features = 5
    features = np.zeros([number_of_files, number_of_features])
    sample_rate = 44100
    for file_index, url in enumerate(filelist):
        print url
        urllib.urlretrieve(url, filename='/tmp/localfile.wav')
        audio = MonoLoader(filename = '/tmp/localfile.wav', sampleRate = sample_rate)()
        zcr = ZeroCrossingRate()
        hamming_window = Windowing(type = 'hamming') 
        spectrum = Spectrum()
        central_moments = CentralMoments()
        distributionshape = DistributionShape()
        spectral_centroid = Centroid()
        frame_size = int(round(0.100 * sample_rate))   
        current_frame = audio[0 : frame_size]
        features[file_index, 0] = zcr(current_frame)
        spectral_magnitude = spectrum(hamming_window(current_frame))
        centroid = spectral_centroid(spectral_magnitude)
        spectral_moments = distributionshape(central_moments(spectral_magnitude))
        features[file_index, 1] = centroid
        features[file_index, 2:5] = spectral_moments
    return features
def spectral_features ( filelist ) : number_of_files = len ( filelist ) number_of_features = 5 features = np . zeros ( [ number_of_files , number_of_features ] ) sample_rate = 44100 for file_index , url in enumerate ( filelist ) : print url urllib . urlretrieve ( url , filename = '/tmp/localfile.wav' ) audio = MonoLoader ( filename = '/tmp/localfile.wav' , sampleRate = sample_rate ) ( ) zcr = ZeroCrossingRate ( ) hamming_window = Windowing ( type = 'hamming' ) spectrum = Spectrum ( ) central_moments = CentralMoments ( ) distributionshape = DistributionShape ( ) spectral_centroid = Centroid ( ) frame_size = int ( round ( 0.100 * sample_rate ) ) current_frame = audio [ 0 : frame_size ] features [ file_index , 0 ] = zcr ( current_frame ) spectral_magnitude = spectrum ( hamming_window ( current_frame ) ) centroid = spectral_centroid ( spectral_magnitude ) spectral_moments = distributionshape ( central_moments ( spectral_magnitude ) ) features [ file_index , 1 ] = centroid features [ file_index , 2 : 5 ] = spectral_moments return features
Given a list of files, retrieve them, analyse the first 100mS of each file and return
a feature table.
Given a list of files retrieve them analyse the first 100mS of each file and return a feature table .
"""
    Given a list of files, retrieve them, analyse the first 100mS of each file and return
    a feature table.
    """ # we need to window the frame to avoid FFT artifacts. # 100ms # Only do the first frame for now. # TODO we should generate values for the entire file, probably by averaging the features.
filelist