Подтвердить что ты не робот

Запись голоса с помощью Java

Я хочу записать голос с помощью приложения Java; Думаю, это будет в основном апплет, который будет работать на стороне клиента. Но я не знаю, как это сделать... любые идеи? Кроме того, я хочу воспроизвести записанный голос.

Я слышал о Java Speech API. Любая идея, если это может помочь?

4b9b3361

Ответ 1

Я опаздываю на вечеринку, но вот официальные документы по захвату аудио: 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);
}