简体   繁体   English

如何将丝绸音频文件从微信号转换为amr格式?

[英]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. 我需要将丝绸文件转换为某种格式,可以通过第3种语音检测服务识别。

Some 3rd services support amr format. 一些第三服务支持amr格式。 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. 多亏了这个项目 ,这是一个很棒的工具,可以将丝绸文件解码为pcm格式。
  3. Installing the ffmpeg, because of some licensing shit, by default, the ffmpeg doesn't support amr, you must install opencore-amr. 安装ffmpeg,因为有些许可狗屎,默认情况下,ffmpeg不支持amr,你必须安装opencore-amr。 The easiest way is brew install ffmpeg --with-opencore-amr --with-speex . 最简单的方法是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. 因为amr格式只支持8kHz,所以项目中的shell(如上所述)不起作用。 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” . 我们必须将第70行中的命令更改为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. 在MacOS上,程序正在将丝绸转换为mp3,你可以稍微操作一下并在其他操作系统上测试amr。

  1. Download lame http://lame.sourceforge.net/ , run 下载跛脚http://lame.sourceforge.net/ ,运行

    ./configure && make && sudo make install

    If you encounter 如果遇到

     Undefined symbols for architecture x86_64: 架构x86_64的未定义符号:\n"_lame_init_old", referenced from: “_lame_init_old”,引自:\n -exported_symbol[s_list] command line option -exported_symbol [s_list]命令行选项\nld: symbol(s) not found for architecture x86_64 ld:找不到架构x86_64的符号\nclang: error: linker command failed with exit code 1 (use -v to see invocation) clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)\n
    Remove line lame_init_old from ${lame}/include/libmp3lame.sym before ./configure ./configure之前从${lame}/include/libmp3lame.sym删除行lame_init_old

  2. Download ffmpeg from http://ffmpeg.org/ , run http://ffmpeg.org/下载ffmpeg,运行

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

    If you encounter 如果遇到

     nasm/yasm not found or too old. nasm / yasm未找到或太旧。 Use --disable-x86asm for a crippled build. 使用--disable-x86asm进行残缺的构建。\n
    . Then run brew install yasm before ./configure 然后在./configure之前运行brew install yasm

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

  4. Run the command to convert silk to mp3. 运行命令将silk转换为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. ${your-silk-v3-decoder-folder}/converter.sh {silk file full path} mp3你会看到mp3文件与输入丝相同的路径。 And the path to silk file MUST be full path. 丝绸档案的路径必须是完整的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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