Search code examples
javascriptphpaudioflacrecorder

How to convert WAV audio file to FLAC format in javascript or php


I am recording audio in wav format using recorder.js https://github.com/mattdiamond/Recorderjs but google's speech API accept only FLAC format of audio. Could anyone guide me either to a FLAC recorder or how to convert the recorded wav file to a FLAC file on client side or server side(linux server).


Solution

  • WAV files can simply converted to FLAC via ffmpeg with this command:

    ffmpeg -i input.wav output.flac
    

    You can find more documents about ffmpeg in the official site, Also there is a php wrapper for the ffmpeg binary on github.