@Test
  public void testExtractFeaturesExtractsFeatures() {
    Word w = new Word(0, 1, "test");
    regions.add(w);

    WavReader reader = new WavReader();
    WavData wav = null;
    try {
      wav = reader.read(TEST_DIR + "/test.wav");
    } catch (UnsupportedAudioFileException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (AuToBIException e) {
      e.printStackTrace();
    }
    w.setAttribute("wav", wav);

    try {
      fe.extractFeatures(regions);
      assertTrue(w.hasAttribute("spectrum"));
    } catch (FeatureExtractorException e) {
      fail();
    }
  }
  @Test
  public void testExtractFeaturesExtractsFeaturesCorrectly() {
    Word w = new Word(0, 1, "test");
    regions.add(w);

    WavReader reader = new WavReader();
    WavData wav = null;
    try {
      wav = reader.read(TEST_DIR + "/bdc-test.wav");
    } catch (UnsupportedAudioFileException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (AuToBIException e) {
      e.printStackTrace();
    }
    w.setAttribute("wav", wav);

    try {
      fe.extractFeatures(regions);
      Spectrum s = (Spectrum) w.getAttribute("spectrum");
      assertEquals(835, s.numFrames());
      assertEquals(256, s.numFreqs());
      // Assume that the spectrum extraction algorithm is tested in SpectrumExtractor.
      // Here we'll make sure that the generated spectrum passes some sanity checks.
    } catch (FeatureExtractorException e) {
      fail();
    }
  }
 @Override
 public void extractFeatures(List regions) throws FeatureExtractorException {
   for (Region r : (List<Region>) regions) {
     if (r.hasAttribute(f1) && r.hasAttribute(f2)) {
       Contour c1, c2;
       try {
         c1 = ContourUtils.getSubContour((Contour) r.getAttribute(f1), r.getStart(), r.getEnd());
         c2 = ContourUtils.getSubContour((Contour) r.getAttribute(f2), r.getStart(), r.getEnd());
       } catch (AuToBIException e) {
         throw new FeatureExtractorException(e.getMessage());
       }
       r.setAttribute("rmse[" + f1 + "," + f2 + "]", contourRMSE(c1, c2));
       r.setAttribute("meanError[" + f1 + "," + f2 + "]", contourError(c1, c2));
     }
   }
 }