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();
        service.setUsernameAndPassword("", "");
        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();
    }
}

@@ -439,24 +439,356 @@
 chToText();%0A
+        String username = System.getenv(%22SPEECH_TO_TEXT_BLUEMIX_USERNAME%22);%0A        String password = System.getenv(%22SPEECH_TO_TEXT_BLUEMIX_PASSWORD%22);%0A        if (username == null %7C%7C password == null) %7B%0A            System.err.println(%22ERROR: BLUEMIX credentials for speech to text is not set.%22);%0A            return null;%0A        %7D%0A
         serv
@@ -818,14 +818,26 @@
 ord(
-%22%22, %22%22
+username, password
 );%0A 

Use environment variables to obtain BLUEMIX credential info.