ffmpegwechatamrsilk

How to convert silk audio file from WeChat to amr format?


When I developing WeChat mini program, I want to achieve the voice control. but the audio provided by WeChat client is silk.

I need to convert the silk file to some format can be recognized by 3rd voice detection service.

Some 3rd services support amr format. It's really great, because the size could be very small.


Solution

  • The steps as follows:

    1. Uploading the silk file to your server.
    2. Decoding the silk file. Thanks to this project, this is an awesome tool for decoding the silk file to pcm format.
    3. Installing the ffmpeg, because of some licensing shit, by default, the ffmpeg doesn't support amr, you must install opencore-amr. The easiest way is brew install ffmpeg --with-opencore-amr --with-speex.
    4. Because the amr format only support 8kHz, so the shell in project(mentioned above) doesn't work. We have to change the command in the 70th line to ffmpeg -y -f s16le -ar 24000 -ac 1 -i "$1.pcm" -ar 8000 "${1%.*}.$2”.