dan@0: function [segments,samples,labels] = read_data_develop(directoryAudio,directoryAnnotation,new_fs) dan@0: %% dan@0: % Mobilab 2012-2013 dan@0: % dan@0: % Input arguments: dan@0: % - directoryAudi: dan@0: % Contains the path to the folder where the data is located dan@0: % - directoryAnnotation: dan@0: % Contains the path to the folders where the annotations are located dan@0: % - new_fs: dan@0: % Resample the .wav files to this sample frequency. If left dan@0: % blank, no resampling occur dan@0: % Output arguments dan@0: % - segments is a cell structure: dan@0: % Columns: # number of development examples dan@0: % Rows: # numer of annotators dan@0: % Each cell contains the segmented files from corresponding dan@0: % development file and annotator dan@0: % - samples is a cell structure: dan@0: % Same structure as segments. Each cell contains the start and dan@0: % stop time of the event. dan@0: % - labels is a cell structure: dan@0: % Same structure as segments. Each cell contains the labels of dan@0: % the corresponding events dan@0: %% Defaults dan@0: down=1; if nargin < 3; down=0; end dan@0: %% Annotation dan@0: addpath(directoryAudio); dan@0: files=find_format(directoryAudio, '.wav'); dan@0: names=files.names; dan@0: nrScripts = length(names); dan@0: dan@0: % Preallocation for speed dan@0: segments=cell(1,nrScripts); dan@0: samples=cell(1,nrScripts); dan@0: labels=cell(1,nrScripts); dan@0: dan@0: for(scriptNr=1:nrScripts) dan@0: dan@0: [x_temp fs] = wavread(names{1,scriptNr}); dan@0: if(down==1) dan@0: x_temp = resample(x_temp,new_fs,fs); dan@0: fs=new_fs; dan@0: end, dan@0: dan@0: dan@0: addpath(directoryAnnotation); dan@0: files2=find_format(directoryAnnotation, 'txt'); dan@0: annotation=textread(files2.names{1,i}, '%s' ,'delimiter', '\t'); dan@0: startStop=zeros(length(annotation)/3,2); dan@0: id=cell(length(annotation)/3,1); dan@0: u=1; dan@0: for(v=1:3:length(annotation)) dan@0: startStop(u,1)=str2num(annotation{v,1}); dan@0: startStop(u,2)=str2num(annotation{v+1,1}); dan@0: x{u,2}=fs; dan@0: x{u,1}=x_temp(ceil(startStop(u,1)*x{u,2})+1:ceil(startStop(u,2)*x{u,2})); dan@0: id{u,1}=annotation{v+2,1}; dan@0: u=u+1; dan@0: end, dan@0: segments{k,i}=x; dan@0: samples{k,i}=startStop; dan@0: labels{k,i}=id; dan@0: rmpath(directoryAnnotation{k,1}); dan@0: clear x; dan@0: end, dan@0: end dan@0: dan@0: dan@0: dan@0: dan@0: dan@0: dan@0: dan@0: dan@0: dan@0: dan@0: dan@0: dan@0: