so I'm making an application to dictate speech into a textbox using IBM Watson Speech to text java API. Essentially I want to remake the demo using a microphone in this link.
I want to remake this in JAVA. So I have this sample code from their documentation
public class SimpleServlet {
private static CountDownLatch lock = new CountDownLatch(1);
public static void main(String[] args) throws FileNotFoundException, InterruptedException {
SpeechToText service = new SpeechToText();
service.setUsernameAndPassword("username","pass");
//FileInputStream audio = new FileInputStream("src/test/resources/4.flac");
AudioInputStream audio = null;
RecognizeOptions options = new RecognizeOptions.Builder()
.continuous(true)
.interimResults(true)
.contentType(HttpMediaType.AUDIO_FLAC)
.build();
service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() {
@Override
public void onTranscription(SpeechResults speechResults) {
System.out.println(speechResults);
if (speechResults.isFinal())
lock.countDown();
}
});
lock.await(1, TimeUnit.MINUTES);
}
}
How would you open a socket to continuously add in an audiostream? If that is even the correct way to go about this.
Any help is appreciated.