package nl.ekholabs.nlp.service;

import edu.cmu.sphinx.api.Configuration;
import org.springframework.stereotype.Service;

@Service
public class SpeechToTextService {

  public String processSpeech(final byte [] input) {
    final Configuration configuration = new Configuration();
    configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
    configuration.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
    configuration.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");


    return null;
  }
}

@@ -38,40 +38,313 @@
 ort 
-edu.cmu.sphinx.api.Configuration
+java.io.ByteArrayInputStream;%0Aimport java.io.FileInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0Aimport edu.cmu.sphinx.api.Configuration;%0Aimport edu.cmu.sphinx.api.SpeechResult;%0Aimport edu.cmu.sphinx.api.StreamSpeechRecognizer;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory
 ;%0Aim
@@ -389,16 +389,57 @@
 rvice;%0A%0A
+import static java.lang.String.valueOf;%0A%0A
 @Service
@@ -475,16 +475,118 @@
 vice %7B%0A%0A
+  private static final Logger LOGGER = LoggerFactory.getLogger(SpeechToTextService.class.getName());%0A%0A
   public
@@ -627,16 +627,35 @@
 %5D input)
+ throws IOException
  %7B%0A    f
@@ -993,24 +993,652 @@
 );%0A%0A
-%0A    return null
+    final StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);%0A    final InputStream stream = new FileInputStream(valueOf(new ByteArrayInputStream(input)));%0A%0A    recognizer.startRecognition(stream);%0A    SpeechResult result;%0A%0A    final StringBuilder output = new StringBuilder();%0A    while ((result = recognizer.getResult()) != null) %7B%0A      result.getWords().stream().forEach(wordResult -%3E %7B%0A        output.append(wordResult.getWord().getSpelling())%0A            .append(' ');%0A      %7D);%0A%0A      LOGGER.info(%22Hypothesis: %25s%22,  result.getHypothesis());%0A    %7D%0A    recognizer.stopRecognition();%0A%0A    return output.toString()
 ;%0A  

Add funcionality to service.