public String trimAudio(String path,double start,double length) throws Exception {
  ArrayList<String> cmd=new ArrayList<String>();
  File file=new File(path);
  String outFile=file.getCanonicalPath() + "_trimmed.wav";
  cmd.add(soxBin);
  cmd.add(path);
  cmd.add("-e");
  cmd.add("signed-integer");
  cmd.add("-b");
  cmd.add("16");
  cmd.add(outFile);
  cmd.add("trim");
  cmd.add(start + "");
  if (length != -1)   cmd.add(length + "");
  int rc=execSox(cmd,callback);
  if (rc != 0) {
    outFile=null;
  }
  if (file.exists())   return outFile;
 else   return null;
}

public String trimAudio ( String path , double start , double length ) throws Exception { ArrayList < String > cmd = new ArrayList < String > ( ) ; File file = new File ( path ) ; String outFile = file . getCanonicalPath ( ) + "_trimmed.wav" ; cmd . add ( soxBin ) ; cmd . add ( path ) ; cmd . add ( "-e" ) ; cmd . add ( "signed-integer" ) ; cmd . add ( "-b" ) ; cmd . add ( "16" ) ; cmd . add ( outFile ) ; cmd . add ( "trim" ) ; cmd . add ( start + "" ) ; if ( length != - 1 ) cmd . add ( length + "" ) ; int rc = execSox ( cmd , callback ) ; if ( rc != 0 ) { outFile = null ; } if ( file . exists ( ) ) return outFile ; else return null ; }
discard all audio not between start and length ( length = end by default ) sox < path > - e signed - integer - b 16 outfile trim < start > < length >
