genPitchLabel_thumb.png

genPitchLabel - generate pitch label

 Generate pseudo labels using the outputs of multiple pitch
 tracking algorithms based on the following rules [1].
   1. certain pitch when all pitch estimation agrees (voiced)
   2. uncertain pitch when pitch estimates disagree (voiced)
   3. uncertain voiced when voicing decisions disagree
   4. certain unvoiced when unvoicing decisions disagree
   You can download a zip file containing genPitchLabel.m and the
   other files used in this demo from genPitchLabel_v1.0.zip.

Contents

----------------------------------------

genPitchLabel FUNCTION:

function [pitch,sad,dc_idx,pf0] = genPitchLabel(f0s,algs,pcf,dispflag)

INPUT:

   f0s: a cell containing pitch track (f0 in Hz)
   algs: a cell containing the names of the algorithms
   pcf: frequencies of pitch candidates
   dispflag: flag for plotting (filename should be changed
   accordingly)
   gthf: ground truth f0 (optional, for plotting only)

OUTPUT:

   pitch: generated pitch label using agreement (pitch index)
   sad: SAD (1/0) + disagreement code (-1: voicing, -2: f0)
   dc_idx: discard decision (when sad = -1 or -2.)
   pf0: generated pitch in f0 (Hz)

REFERENCE:

   [1] Byung Suk Lee
       Noise Robust Pitch Tracking by Subband
       Autocorrelation Classification (SAcC)
       PhD Thesis, Columbia University, 2012
----------------------------------------

USAGE:

A demo of genPitchLabel is provided, to try:

demo_genPitchLabel.m

This will generate pitch label using agreements of Wu, YIN, and get_f0 outputs. For YIN, aperiodicy is used to threshold voicing. The following files are used in the demo.

Input files:

   The "dat/fda/wu/" folder contains the Wu algorithm output files:
   rl001.pitch
   rl002.pitch
   The "dat/fda/yin/" folder contains the YIN output files:
   rl001.yin
   rl002.yin
   The "dat/fda/gf0/" folder contains the get_f0 output files:
   rl001.gf0
   rl002.gf0
   The "dat/fda/gth/" folder contains the ground truth f0 files:
   rl001.gth
   rl002.gth

Output files:

   The following output files of genPitchLabel are saved to "out/fda/" folder:
   rl001.gpl
   rl002.gpl
% Get 24 pitch candidates per octave from 60Hz to around 400Hz
fmin = 60; nPitchPerOctave = 24; fmax = 400;
tmax = round(nPitchPerOctave*log2(fmax/fmin))/nPitchPerOctave;
t = 0:(1/nPitchPerOctave):tmax;
pcf = fmin*2.^t;

% Use Wu, YIN, get_f0 agreement to generate the pseudo label
dispflag = 1;
algs = {'wu','yin','gf0'};
exts = {'.pitch','.yin','.gf0'};
files = {'rl001','rl002'};
gpl_ext = '.gpl';
nalgs = length(algs);
in_path = 'dat/fda/';
out_path = 'out/fda/';
if ~exist(out_path,'dir'), mkdir(out_path); end;

for c = 1:length(files)
    out_fn = [out_path,files{c},gpl_ext];
    disp(['Generating output: ',out_fn])
    maxl = 0;
    f0s = cell(1,nalgs);
    for alg = 1:nalgs
        fn_ext = exts{alg};
        fn = [in_path,algs{alg},'/',files{c},fn_ext];
        disp(['Processing pitch: ',fn])
        f0s{alg} = dlmread(fn);
        if ~isempty(strfind(fn_ext,'.sacc')) % for SAcC (not used here)
        f0s{alg} = f0s{alg}(:,3);
        elseif ~isempty(strfind(fn_ext,'.gf0'))
        f0s{alg} = f0s{alg}(:,1);
        elseif ~isempty(strfind(fn_ext,'.yin'))
        ap0 = f0s{alg}(:,2);
        f0s{alg} = f0s{alg}(:,1);
        % use ap0 < 0.3 for SAD
        f0s{alg}(ap0 > 0.3) = 0;
        end
        f0s{alg}(isnan(f0s{alg})) = 0;
        f0s{alg}(isinf(f0s{alg})) = 0;
        maxl = max(maxl,length(f0s{alg}));
    end
    for alg = 1:nalgs
        if length(f0s{alg}) < maxl
            f0s{alg}(end+1:maxl) = f0s{alg}(end);
        end
    end
    gthfn = [in_path,'gth/',files{c},'.gth'];
    gthf = dlmread(gthfn);
    [pitch,sad,dc_idx,pf0] = genPitchLabel(f0s,algs,pcf,dispflag,gthf);
    if ~exist(out_fn,'file')
    dlmwrite(out_fn,pitch)
    end
    ptf = pitch;
    ptf(pitch < 0) = 0;
end
Generating output: out/fda/rl001.gpl
Processing pitch: dat/fda/wu/rl001.pitch
Processing pitch: dat/fda/yin/rl001.yin
Processing pitch: dat/fda/gf0/rl001.gf0
Generating output: out/fda/rl002.gpl
Processing pitch: dat/fda/wu/rl002.pitch
Processing pitch: dat/fda/yin/rl002.yin
Processing pitch: dat/fda/gf0/rl002.gf0

----------------------------------------

CONTACT:

  Byung Suk Lee, bsl@ee.columbia.edu
  LabROSA, Columbia University, 2012-09-13

Valid HTML 4.0! Last updated: $Date: 2012/09/16 22:18:57 $
Byung Suk Lee <bsl@ee.columbia.edu>