Question

I'm working on a software (in java) using speech recognition with Sphinx4 API.
In order to reduce interferences, I wanted to record 2 sounds on 2 differents microphones (one for the speaker (A) and another one to record "the environment" (B)), and then do A-B to obtain an "interferenceless" sound that I give to Sphinx for recognition. I think that java.sound can do stuff like that but I don't really know how to do that.

  • Do you think this kind of solution can work?
  • Is it possible to do that in real time? if yes what kind of hardware configuration does it need?
  • Do you have some helpful links / code for my case?
Was it helpful?

Solution

Java Sound per se cannot do such signal processing. But you can get the raw audio data in realtime from the microphones, process it yourself, then pass on to Sphinx4.

For accessing 2 microphones, query the available mixers in AudioSystem, then choose the 2 mixers corresponding to the two microphones. From each mixer, get a SourceDataLine and use it to capture the audio data.

You can process the data in real time, just make sure to use a suitable buffer size on the SourceDataLine. A buffer size corresponding to 20ms should work on most systems.

Most hardware should work fine. There are "direct" SourceDataLine's on Windows and Linux available. Your mileage on OS X will vary (depending onJava implementation).

www.jsresources.org has a number of programming examples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top