wav文件转成g722, g729编码的文件

阅读: 评论:0

wav文件转成g722, g729编码的文件

wav文件转成g722, g729编码的文件

语音系统中经常需要各种编码的音频原始文件(raw file),使用Asterisk 这个著名的IP-PBX软件附带的转码功能就可以实现。

它根据文件的后缀来确定编码格式。


如果asterisk已经在运行,使用asterisk -r 可以进入asterisk的命令行。

"file convert "命令的使用方法:

dev12*CLI> file convert
Usage: file convert <file_in> <file_out>
       Convert from file_in to file_out. If an absolute path
       is not given, the default Asterisk sounds directory
       will be used.

       Example:
           file convert tt-weasels.gsm tt-weasels.ulaw


如果是在脚本里面运行,可以使用rasterisk工具,例如:

rasterisk -x "file convert /tmp/file_in.alaw /tmp/file_out.ulaw"


批量转换的例子:

To ilbc
    for a in *.wav; do rasterisk -x "file convert /var/lib/asterisk/sounds/custom/$a /var/lib/asterisk/sounds/custom/`echo $a|sed "s/.wav/.ilbc/"`"; done;


To g729
     for a in *.wav; do rasterisk -x "file convert /var/lib/asterisk/sounds/custom/$a /var/lib/asterisk/sounds/custom/`echo $a|sed "s/.wav/.g729/"`"; done;

注意:

Asterisk only accepts .wav files with 8kHz sampling rate. 16kHz sampled .wav files are not acceptable. But you CAN convert from sln16 (signed linear 16kHz sampling rate, 16bit resolution) to g.722.
The trick then is getting your audio file to be an sln16 file in the first place.

This is simply a raw PCM file, as opposed to .wav. In Cool Edit Pro (I guess you can do the same with Audacity but haven't tried myself) simply save your 16kHz sample rate file as "PCM Raw Data" instead of .wav, which gives it the extension .pcm. You can then just change the file extension from pcm to sln16 before copying the file into Asterisk (with WinSCP or whatever). You then have your own wideband custom promt。



另外一个工具是sox, 它可以转换采样率,保存为不同的格式。

参考:

+WAV+audio+files+for+use+in+Asterisk




本文发布于:2024-02-01 21:50:35,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170679543639637.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:文件   转成   wav
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23