简体   繁体   中英

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.

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” .

On MacOS, the procedure is working for converting silk to mp3, you may manipulate a little bit and test on other OS for amr.

  1. Download lame http://lame.sourceforge.net/ , run

    ./configure && make && sudo make install

    If you encounter

     Undefined symbols for architecture x86_64: \n"_lame_init_old", referenced from: \n -exported_symbol[s_list] command line option \nld: symbol(s) not found for architecture x86_64 \nclang: error: linker command failed with exit code 1 (use -v to see invocation) \n
    Remove line lame_init_old from ${lame}/include/libmp3lame.sym before ./configure

  2. Download ffmpeg from http://ffmpeg.org/ , run

    ./configure --enable-libmp3lame && make && sudo make install

    If you encounter

     nasm/yasm not found or too old.  Use --disable-x86asm for a crippled build. \n
    . Then run brew install yasm before ./configure

  3. Download https://github.com/kn007/silk-v3-decoder

  4. Run the command to convert silk to mp3.

    ${your-silk-v3-decoder-folder}/converter.sh {silk file full path} mp3 And you will see the mp3 file in the same path as the input silk. And the path to silk file MUST be full path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM