function seg = erode_seg( seg, erosion_sec, t_min, t_max, small_time )

  if nargin < 2
    error( [ mfilename ' needs at least 2 input argument.' ] );
  end


  % Something to do?

  if isempty( seg )
    return;
  end

  if size( seg, 1 ) ~= 2
    error( [ mfilename ' needs a 2-row matrix for "seg" (speech segments only, row 1: start times, row 2: finish times).' ] );
  end

  if ~exist( 't_min', 'var' )
    t_min = -Inf;
  end

  if ~exist( 't_max', 'var' )
    t_max = +Inf;
  end
  
  if ~exist( 'small_time', 'var' )
    small_time = 1e-10;
  end

  
  % Do it!

  seg_middle = mean( seg, 1 );

  % Erode towards the future
  seg( 1,: ) = min( seg( 1,: ) + erosion_sec, seg_middle );

  % Erode towards the past
  seg( 2,: ) = max( seg( 2,: ) - erosion_sec, seg_middle );

  % Simplify
  seg = simplify_seg( seg, small_time );
  