11
我想使用Java應用程序錄制語音;我想這將基本上是一個將在客戶端運行的applet。但我不知道如何去做......任何想法?另外,我想播放錄製的聲音。使用Java錄製語音
我聽說過Java Speech API。任何想法,如果它可以幫助?
我想使用Java應用程序錄制語音;我想這將基本上是一個將在客戶端運行的applet。但我不知道如何去做......任何想法?另外,我想播放錄製的聲音。使用Java錄製語音
我聽說過Java Speech API。任何想法,如果它可以幫助?
我遲到了,但這裏有上捕獲音頻的官方文檔:http://docs.oracle.com/javase/tutorial/sound/capturing.html
(直接從上面這裏的鏈接複製是一些示例代碼做到這一點:)
TargetDataLine line;
DataLine.Info info = new DataLine.Info(TargetDataLine.class,
format); // format is an AudioFormat object
if (!AudioSystem.isLineSupported(info)) {
// Handle the error ...
}
// Obtain and open the line.
try {
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format);
} catch (LineUnavailableException ex) {
// Handle the error ...
}
// Assume that the TargetDataLine, line, has already
// been obtained and opened.
ByteArrayOutputStream out = new ByteArrayOutputStream();
int numBytesRead;
byte[] data = new byte[line.getBufferSize()/5];
// Begin audio capture.
line.start();
// Here, stopped is a global boolean set by another thread.
while (!stopped) {
// Read the next chunk of data from the TargetDataLine.
numBytesRead = line.read(data, 0, data.length);
// Save this chunk of data.
out.write(data, 0, numBytesRead);
}
看看:http://ditra.cs.umu.se/jmf2_0-guide-html/JMFCapturing.html – pingw33n 2011-01-28 08:34:37
@ pingw33n - 太完整了解你的例子中的 – Varun 2011-01-28 11:03:27