Recognito { public List<MatchResult<K>> identify(double[] voiceSample) { if(store.isEmpty()) { throw new IllegalStateException("There is no voice print enrolled in the system yet"); } VoicePrint voicePrint = new VoicePrint(extractFeatures(voiceSample, sampleRate)); DistanceCalculator calculator = new EuclideanDistanceCalculator(); List<MatchResult<K>> matches = new ArrayList<MatchResult<K>>(store.size()); double distanceFromUniversalModel = voicePrint.getDistance(calculator, universalModel); for (Entry<K, VoicePrint> entry : store.entrySet()) { double distance = entry.getValue().getDistance(calculator, voicePrint); int likelihood = 100 - (int) (distance / (distance + distanceFromUniversalModel) * 100); matches.add(new MatchResult<K>(entry.getKey(), likelihood, distance)); } Collections.sort(matches, new Comparator<MatchResult<K>>() { @Override public int compare(MatchResult<K> m1, MatchResult<K> m2) { return Double.compare(m1.getDistance(), m2.getDistance()); } }); return matches; } Recognito(float sampleRate);  Recognito(float sampleRate, Map<K, VoicePrint> voicePrintsByUserKey); VoicePrint getUniversalModel(); synchronized void setUniversalModel(VoicePrint universalModel); synchronized VoicePrint createVoicePrint(K userKey, double[] voiceSample); VoicePrint createVoicePrint(K userKey, File voiceSampleFile); VoicePrint mergeVoiceSample(K userKey, double[] voiceSample); VoicePrint mergeVoiceSample(K userKey, File voiceSampleFile); List<MatchResult<K>> identify(double[] voiceSample); List<MatchResult<K>> identify(File voiceSampleFile);  }
@Test(expected = IllegalStateException.class) public void identifyBreaksWhenNoVoicePrintWasPreviouslyExtracted() { recognito.identify(voiceSample); }