Возможно, с помощью JAVE2 для конвертации из webm в mp3 (или другой).
https://github.com/a-schild/jave2
Пример в файле readme должен указывать вам правильное направление:
try {
File source = new File("file path"); // Path to your webm
File target = new File("file path"); // Output path
//Audio Attributes
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame"); // Change this to flac if you prefer flac
audio.setBitRate(128000);
audio.setChannels(2);
audio.setSamplingRate(44100);
//Encoding attributes
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3"); // Change to flac if you prefer flac
attrs.setAudioAttributes(audio);
//Encode
Encoder encoder = new Encoder();
encoder.encode(new MultimediaObject(source), target, attrs);
// The target file should now be present at the path specified above
} catch (Exception ex) {
ex.printStackTrace();
}
После преобразования у вас будет файловый объект, который можно преобразовать в байт [] для отправки речи в текстовый API, как в следующем примере:
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/speech/cloud-client/src/main/java/com/example/speech/QuickstartSample.java