Implementing Microsoft.CognitiveServices.Speech recognition for several files

I have gotten the coding example from here to work.

I can run a .wav file through and get the transcript, however in the example the program never ends until I hit a key:

System.out.println("Press any key to stop");
new Scanner(System.in).nextLine();

That seems to artificially pause everything while the service is being queried. If I remove those that line, the program jumps through to fast and concludes without waiting for the service to respond.

Question: How do I resume/continue the program with the full transcription without needing to hit a key?

I would like to run this for multiple .wav files transcribing each one after the other. But so far it runs the first one then waits.

I have been scouring the documentation and I have tried multiple things including using recognizer.close(); which I would expect to end the SpeechRecognizer but which seems to do nothing.

Or using result = recognizer.recognizeOnceAsync().get(); which does not transcribe the full file.

Does anyone know of an example of this running multiple files or how to implement that?

Thanks.