Home > data-import > make_audio_mat.m

make_audio_mat

PURPOSE ^

Converts speech_r/*.wav file into a matlab variable with the correct

SYNOPSIS ^

function make_audio_mat(IDs)

DESCRIPTION ^

 Converts speech_r/*.wav file into a matlab variable with the correct
 timing information based on _info.txt. This stream is compressed by a
 factor of 100 so that it can easily load into visualization programs.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function make_audio_mat(IDs)
0002 % Converts speech_r/*.wav file into a matlab variable with the correct
0003 % timing information based on _info.txt. This stream is compressed by a
0004 % factor of 100 so that it can easily load into visualization programs.
0005 subs = cIDs(IDs);
0006 
0007 dsfactor = 100;
0008 for s = 1:numel(subs);
0009     try
0010     path = get_subject_dir(subs(s));
0011     d = dir(fullfile(path, 'speech_r', '*.wav'));
0012     if isempty(d)
0013         d = dir(fullfile(path, 'speech_r', '*.mp3'));
0014     end
0015     path = fullfile(path, 'speech_r', d.name);
0016     [y,fs] = audioread(path);
0017     re = downsample(y(:,1), dsfactor);
0018     time = (0:size(re,1)-1)';
0019     time = time/fs*dsfactor;
0020     info = get_timing(subs(s));
0021     offset = info.speechTime;
0022     time = time + offset;
0023     all = [time re];
0024     %get just in trial portion
0025     tri = get_trial_times(subs(s));
0026     [~,idx1] = min(abs(all(:,1)-tri(1)));
0027     [~,idx2] = min(abs(all(:,1)-tri(end)));
0028     all = all(idx1:idx2,:);
0029     record_variable(subs(s), 'cont_audio_file', all);
0030     catch ME
0031         continue
0032     end
0033 end

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005