3

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.

hzwzw
  • 1,042
  • 12
  • 17

2 Answers2

2

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”.
hzwzw
  • 1,042
  • 12
  • 17
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:
    "_lame_init_old", referenced from:
     -exported_symbol[s_list] command line option
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
    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.
    
    . 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.

Popeye
  • 2,002
  • 20
  • 14