package Ming;

import com.ibm.watson.developer_cloud.speech_to_text.v1.SpeechToText;
import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechResults;
import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Transcript;

import java.io.File;
import java.util.List;

// TODO: Abstract the service provider.
public class SpeechToTextService {
    public String recognize(File audio) {
        SpeechToText service = new SpeechToText();
        String username = System.getenv("SPEECH_TO_TEXT_BLUEMIX_USERNAME");
        String password = System.getenv("SPEECH_TO_TEXT_BLUEMIX_PASSWORD");
        if (username == null || password == null) {
            System.err.println("ERROR: BLUEMIX credentials for speech to text is not set.");
            return null;
        }
        service.setUsernameAndPassword(username, password);
        SpeechResults results = service.recognize(audio).execute();
        List<Transcript> result = results.getResults();
        StringBuilder builder = new StringBuilder();
        for (int j = 0; j < result.size(); j++) {
            for (int i = 0; i < result.get(j).getAlternatives().size(); i++) {
                builder.append(i + ": \"");
                builder.append(result.get(j).getAlternatives().get(i).getTranscript());
                builder.append("\"\n");
            }
        }
        return builder.toString();
    }
}

@@ -78,16 +78,96 @@
 ToText;%0A
+import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions;%0A
 import c
@@ -970,16 +970,107 @@
 ze(audio
+, new RecognizeOptions.Builder()%0A                .continuous(true)%0A                .build()
 ).execut

Use RecognizeOptions.