public void load(String fileName) throws IOException, MaryConfigurationException {
  DataInputStream dis=null;
  try {
    dis=new DataInputStream(new BufferedInputStream(new FileInputStream(fileName)));
  }
 catch (  FileNotFoundException e) {
    throw new RuntimeException("File [" + fileName + "] was not found.");
  }
  try {
    hdr=new MaryHeader(dis);
    if (hdr.getType() != MaryHeader.LISTENERFEATS) {
      throw new RuntimeException("File [" + fileName + "] is not a valid Mary Units file.");
    }
    windowSize=dis.readFloat();
    if (this.windowSize <= 0) {
      throw new RuntimeException("File [" + fileName + "] has a negative number for window size. Aborting.");
    }
    skipSize=dis.readFloat();
    if (this.skipSize <= 0) {
      throw new RuntimeException("File [" + fileName + "] has a negative number for window size. Aborting.");
    }
    numberOfUnits=dis.readInt();
    if (numberOfUnits < 0) {
      throw new RuntimeException("File [" + fileName + "] has a negative number of units. Aborting.");
    }
    contours=new double[numberOfUnits][];
    coeffs=new double[numberOfUnits][];
    voiced=new boolean[numberOfUnits][];
    for (int i=0; i < numberOfUnits; i++) {
      int polyOrder=dis.readInt();
      coeffs[i]=new double[polyOrder];
      for (int j=0; j < polyOrder; j++) {
        coeffs[i][j]=dis.readFloat();
      }
      int f0ContourLength=dis.readInt();
      contours[i]=new double[f0ContourLength];
      voiced[i]=new boolean[f0ContourLength];
      Arrays.fill(voiced[i],false);
      for (int j=0; j < f0ContourLength; j++) {
        contours[i][j]=dis.readFloat();
        if (contours[i][j] > 0) {
          voiced[i][j]=true;
        }
      }
    }
  }
 catch (  IOException e) {
    throw new RuntimeException("Reading the Mary header from file [" + fileName + "] failed.",e);
  }
}

public void load ( String fileName ) throws IOException , MaryConfigurationException { DataInputStream dis = null ; try { dis = new DataInputStream ( new BufferedInputStream ( new FileInputStream ( fileName ) ) ) ; } catch ( FileNotFoundException e ) { throw new RuntimeException ( "File [" + fileName + "] was not found." ) ; } try { hdr = new MaryHeader ( dis ) ; if ( hdr . getType ( ) != MaryHeader . LISTENERFEATS ) { throw new RuntimeException ( "File [" + fileName + "] is not a valid Mary Units file." ) ; } windowSize = dis . readFloat ( ) ; if ( this . windowSize <= 0 ) { throw new RuntimeException ( "File [" + fileName + "] has a negative number for window size. Aborting." ) ; } skipSize = dis . readFloat ( ) ; if ( this . skipSize <= 0 ) { throw new RuntimeException ( "File [" + fileName + "] has a negative number for window size. Aborting." ) ; } numberOfUnits = dis . readInt ( ) ; if ( numberOfUnits < 0 ) { throw new RuntimeException ( "File [" + fileName + "] has a negative number of units. Aborting." ) ; } contours = new double [ numberOfUnits ] [ ] ; coeffs = new double [ numberOfUnits ] [ ] ; voiced = new boolean [ numberOfUnits ] [ ] ; for ( int i = 0 ; i < numberOfUnits ; i ++ ) { int polyOrder = dis . readInt ( ) ; coeffs [ i ] = new double [ polyOrder ] ; for ( int j = 0 ; j < polyOrder ; j ++ ) { coeffs [ i ] [ j ] = dis . readFloat ( ) ; } int f0ContourLength = dis . readInt ( ) ; contours [ i ] = new double [ f0ContourLength ] ; voiced [ i ] = new boolean [ f0ContourLength ] ; Arrays . fill ( voiced [ i ] , false ) ; for ( int j = 0 ; j < f0ContourLength ; j ++ ) { contours [ i ] [ j ] = dis . readFloat ( ) ; if ( contours [ i ] [ j ] > 0 ) { voiced [ i ] [ j ] = true ; } } } } catch ( IOException e ) { throw new RuntimeException ( "Reading the Mary header from file [" + fileName + "] failed." , e ) ; } }
load the given unit file
