-3

I search through Github and Google, but not found a good solution.

background: I'm writing a Telegram bot and want to transcript user's voice message to text using Microsoft's speech-to-text java sdk, the sdk only accept wav files, so I need to first transform ogg files to wav files.

I want to find a solution to convert ogg file to wav using Java.

djy
  • 737
  • 6
  • 14
  • 2
    Does this answer your question? [Java ogg to wav conversion](https://stackoverflow.com/questions/15387380/java-ogg-to-wav-conversion) – life888888 Feb 24 '23 at 02:41
  • that thread seems suggesting using old utils https://github.com/bramp/ffmpeg-cli-wrapper I am going to try this. – djy Feb 24 '23 at 03:09
  • When looking for an answer on Stackoverflow, I choose the answer that has more votes and is marked as the answer. – life888888 Feb 24 '23 at 03:45

1 Answers1

0

finally, I used ffmpeg https://www.ffmpeg.org/ to transform first, it works. Installation of ffmpeg required to run this code

            String fileName = file.getName();
            String wavFileName = fileName + ".wav";
            String cmd = "ffmpeg -i " + fileName + " ./" + wavFileName;
            try {
                Process p = Runtime.getRuntime().exec(cmd);
                p.waitFor();
            } catch (IOException e) {
                throw new RuntimeException(e);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

djy
  • 737
  • 6
  • 14