use of javax.sound.sampled.TargetDataLine in project aws-doc-sdk-examples by awsdocs.
the class BidirectionalStreaming method get.
// snippet-end:[transcribe.java2.bidir_streaming.main]
public static TargetDataLine get() throws Exception {
AudioFormat format = new AudioFormat(16000, 16, 1, true, false);
DataLine.Info datalineInfo = new DataLine.Info(TargetDataLine.class, format);
TargetDataLine dataLine = (TargetDataLine) AudioSystem.getLine(datalineInfo);
dataLine.open(format);
return dataLine;
}
use of javax.sound.sampled.TargetDataLine in project java-google-speech-api by goxr3plus.
the class GSpeechDuplex method upChannel.
/**
* Streams data from the TargetDataLine to the API.
*
* @param urlStr
* The URL to stream to
* @param tl
* The target data line to stream from.
* @param af
* The AudioFormat to stream with.`
* @throws LineUnavailableException
* If cannot open or stream the TargetDataLine.
*/
private Thread upChannel(String urlStr, TargetDataLine tl, AudioFormat af) throws LineUnavailableException {
final String murl = urlStr;
final TargetDataLine mtl = tl;
final AudioFormat maf = af;
if (!mtl.isOpen()) {
mtl.open(maf);
mtl.start();
}
Thread upChannelThread = new Thread("Upstream Thread") {
public void run() {
openHttpsPostConnection(murl, mtl, (int) maf.getSampleRate());
}
};
upChannelThread.start();
return upChannelThread;
}
Aggregations