Hello everyone, I am new to Asterisk. Recently I am given a task to automatically record calls using Asterisk. The required sample rate is 8000 and sample encoding is “8-bit a-law”. Now I am using Monitor() in extensions.conf to make audio recording. However, the sample encoding of generated recordings is “16-bit Signed Integer PCM”.
I thought there should exist some methods for me to change the sample encoding, but I didn’t find it. Then I tried to change it using sox like this in hangup handler:
exten => _x.,n,System(sox “/home/telephone/asterisk_recording/${CALLERID(number)}/${FILENAME}-in_temp.wav” -b 8 -e a-law “/home/telephone/asterisk_recording/${CALLERID(number)}/${FILENAME}-in.wav”)
The first wav file in this command is the original audio make by Monitor(), and the second is what I want. But it cannot give me satisfying result. No matter how long the original audio is, the volume of second file is only 58 bytes with no length and cannot be played. If I run the same command in Terminal after the call is finished, then everything goes fine.
I also tried StopMonitor(), but it didn’t work.
So, I wonder is there any way for me to set the sample rate and sample encoding of audios generated by Monitor() without running other commands out of Asterisk?
Thanks.