@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(); } }