[asterisk-users] Asterisk does not translate from wav to alaw

Bryant Zimmerman BryantZ at zktech.com
Sat Aug 28 10:35:59 CDT 2010


  On Sat, Aug 28, 2010 at 3:22 AM, Jonas Kellens <jonas.kellens at telenet.be> 
wrote:
  Hello list,

I have a file to be played in wav-format.

I thought Asterisk would automatically take the wav-file and translate it 
to the codec used, but I see this :

[Aug 28 11:16:29] WARNING[2705]: file.c:664 ast_openstream_full: File 
/var/lib/asterisk/sounds/vprompts/zip-code.wav does not exist in any 
format
[Aug 28 11:16:29] WARNING[2705]: file.c:991 ast_streamfile: Unable to open 
/var/lib/asterisk/sounds/vprompts/zip-code.wav (format 0x8 (alaw)): No such 
file or directory
[Aug 28 11:16:29] WARNING[2705]: pbx.c:5752 pbx_builtin_background: 
ast_streamfile failed on SIP/test1-0000000f for 
/var/lib/asterisk/sounds/vprompts/zip-code.wav

Am I missing a module to translate from wav to alaw/gsm/g726/... ??

  My guess is that your .wav file is NOT 8khz. The system doesn't accept 
anything but wav files at 8khz. Use 
sox to downsample to 8khz (and 1 chan), and the problems should go away. 
While you are at it, you could use sox to convert
to the target format in a single operation.

The scripts that Digium uses to take Allison's voice prompts (at 48khz) to 
the different formats,  convert things to slin (raw) as a central
format, but in my experience, the fewer steps the better. But I doubt that 
anyone could detect the difference in the end result...

Here's what I do with CD-qual sounds to turn them into the common Asterisk 
formats:

Assume $i is the name of the .wav file you want to convert:

 x=`basename $i .wav`
sox -v 0.7  $i -r 16000 -c 1 -t sw $x.sln16
sox -v 0.7 $i -r 8000 -c 1 -t sw $x.raw
sox -r 8000 -c 1 -t sw $x.raw  -t gsm $x.gsm        ##  OR ###  sox -v 0.7 
$i -r 8000 -t gsm  $x.gsm
sox -r 8000 -c 1 -t sw $x.raw -t ul $x.ulaw            ##  OR ###  sox -v 
0.7  $i -r 8000 -t ul  $x.ulaw
sox -r 8000 -c 1 -t sw $x.raw  -t al $x.alaw           ##  OR ###   sox -v 
0.7 $i -r 8000 -t wav  $x.wav
rm $x.raw
 y=`pwd`
sudo asterisk -rx "file convert $y/$i  $y/$x.g722"

I'm ignoring the siren & g729 formats; use asterisk for those in like 
format, depending on your asterisk version and codecs.
Allison normalizes the volume of sounds she distributes; use the -v 0.7 to 
bring the volume down a bit to
the standard, and your sounds won't stick out against rest of Allison's 
existing recordings in Asterisk.
Digium uses a filter program to 'heighten' the sounds a little; That's the 
main reason, I think, that they
use the .raw format as an in-between. I've been skipping this step, as it 
doesn't seem critical, in which
case the direct conversion is probably preferable.

I suggest, that if you are converting sounds for Asterisk's sake, that you 
convert to all the possible
formats. Disk space is cheap, and you'll squeeze a little extra performance 
out of Asterisk by allowing
it to pick the 'best' format. Dahdi type interfaces would prefer the 
ulaw/alaw formats;  High-def phones
like Snom (and appropriate Polycoms, etc) could use the g722. Ulaw and gsm 
transcodings are cheap,
but no transcoding is cheaper still.

murf

Steve

Thanks for sharing I appericate your insight as this is something I run up 
against as well. 
What about g729 we use this coded a lot what is the best method to 
transcode it it?

Thanks
Bryant

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100828/6d395db2/attachment.htm 


More information about the asterisk-users mailing list