Unable to Playback Custom Audio Files in Asterisk

Hello,

I am encountering an issue with playing back custom audio files in Asterisk. I have tried multiple formats including WAV, SLN, and GSM with 8000 Hz mono sound, but none of them work. The only audio file that plays successfully is the default “hello world” sound.

Here are the steps I have followed:

  1. I placed the custom audio file in the /var/lib/asterisk/sounds/ directory.
  2. I provided the necessary permissions and ownership to the Asterisk user:

sh

Copy code

sudo chmod 644 /var/lib/asterisk/sounds/output222.wav
sudo chown asterisk:asterisk /var/lib/asterisk/sounds/output222.wav
  1. I used the following dialplan configuration to attempt to play the audio file:
> 
> [incoming]
> exten => 1,1,NoOp(Incoming call from ${CALLERID(num)})
>  same => n,Answer()
>  same => n,Playback(output222) ; Attempt to play custom audio file
>  same => n,Hangup()

Despite following these steps, the call drops immediately without playing the custom audio file. Here are some logs that might be relevant:

Executing [1@incoming:1] NoOp("PJSIP/sipnet_endpoint-00000000", "Incoming call from +2") in new stack
Executing [1@incoming:2] Answer("PJSIP/sipnet_endpoint-00000000", "") in new stack
Executing [1@incoming:3] Playback("PJSIP/sipnet_endpoint-00000000", "output222") in new stack
[WARNING] file.c:804 ast_openstream_full: File /var/lib/asterisk/sounds/output222 does not exist in any format
[WARNING] app_playback.c:497 playback_exec: Playback failed on PJSIP/sipnet_endpoint-00000000 for output222
Executing [1@incoming:4] Hangup("PJSIP/sipnet_endpoint-00000000", "") in new stack

System Details:

  • Asterisk Version: 18.10.0
  • OS: Ubuntu

I have verified that the file exists and is in the correct directory. The file permissions and ownership are set correctly. I have also tried converting the file to different formats (WAV, SLN, GSM) using sox, but the issue persists.

Could someone please help me understand what might be going wrong and how to resolve this issue?

Thank you!

Have you tried adding the file name extension?

@cable
yes, it didnt help

That would definitely result in this error message. The extension must not be present for local files.

yeah. but in my case both variants resulted in such error mesage :slightly_smiling_face:
is it depends on folder/format or smth else?

On Friday 28 June 2024 at 12:29:33, jiggo089 via Asterisk Community wrote:

sudo chmod 644 /var/lib/asterisk/sounds/output222.wav
sudo chown asterisk:asterisk /var/lib/asterisk/sounds/output222.wav

Suggestions:

  1. Show us the ownership and permissons of each directory down through the
    path /var /var/lib /var/lib/asterisk /var/lib/asterisk/sounds

  2. What’s the output of “file /var/lib/asterisk/sounds/output222.wav”?

  3. What does “ps auwx” show for the user which Asterisk is running as?

  4. You say that “the default Hello World sound” plays okay.

a) is this file in the same directory?

b) what is its filename?

c) what happens if you copy its content to
/var/lib/asterisk/sounds/sound222.XXX where XXX is the same extension as the
original Hello World file and then try to play sound222?

Antony.


Python is executable pseudocode.
Perl is executable line noise.

                                               Please reply to the list;
                                                     please *don't* CC me.
1 Like

Check your /etc/asterisk/modules.conf file to make sure you have the supported codecs and file formats:

; Codecs

load = codec_gsm.so
load = codec_resample.so
load = codec_ulaw.so
load = codec_g722.so

; Formats

load = format_gsm.so
load = format_pcm.so
load = format_wav_gsm.so
load = format_wav.so

Primarily you’d need format_pcm.so and format_wav.so loaded. You probably need codec_resample as well if your wav files aren’t 8khz/16bit.

1 Like

1/ownership and permissons

drwxr-xr-x 14 root root 4096 Jun 23 21:00 /var
drwxr-xr-x 46 root root 4096 Jun 23 21:00 /var/lib
drwxr-xr-x 15 asterisk asterisk 4096 Jun 23 12:44 /var/lib/asterisk
drwxr-xr-x 4 asterisk asterisk 4096 Jun 28 09:44 /var/lib/asterisk/sounds

2/ output222.wav file has following parameters:

/var/lib/asterisk/sounds/output222.wav: RIFF (little-endian) data, WAVE audio, ITU G.711 A-law, mono 8000 Hz
-rw-r--r-- 1 asterisk asterisk 39996 Jun 28 08:29 /var/lib/asterisk/sounds/output222.wav

3/ ps auwx content:

asterisk  282693  1.5  8.4 774600 83304 ?        Ssl  14:05   0:09 /usr/sbin/asterisk -g -f -p -U asterisk
asterisk  282694  0.0  0.0   2644   932 ?        S    14:05   0:00 astcanary /var/run/asterisk/alt.asterisk.canary.tweet.tweet.tweet 282693
root      282783  0.0  0.5  11900  5464 pts/1    S+   14:06   0:00 sudo asterisk -rvvv
root      282784  0.0  0.0  11900   892 pts/2    Ss   14:06   0:00 sudo asterisk -rvvv
root      282785  0.0  0.9  55912  9556 pts/2    S+   14:06   0:00 rasterisk rvvv
ubuntu    282963  0.0  0.2   7008  2144 pts/3    S+   14:15   0:00 grep --color=auto asterisk

4/ regarding Hello-world file:
a) i have this file both in /var/lib/asterisk/sounds and in /var/lib/asterisk/sounds/en folders.
b) hello-world.gsm
c) changed Hello-world.gsm filename into sound333.gsm. after specifying full path asterisk returned correct playback “hello world”
same => n,Playback(/var/lib/asterisk/sounds/en/sound333)

i’ve added these strings, they are in running status, but blayback still is not working

I saw a post where your wav is alaw.

That might be screwing it up. Typically for wav it expects 8khz/16bit PCM. If you’re running alaw or ulaw then it expects headerless raw files with the .*law extension.

I still wonder if this isn’t a situation where you’re missing a codec or file handler. There could be something messed up with your paths. Usually the default sounds path will be /var/lib/asterisk/sounds/{language}/, so /var/lib/asterisk/sounds/en/ is where it defaults to audio files for channels set to english. It’s possible to change the default language of the PBX or a specific call channel and pull an entirely different set of audio files for that language.

1 Like

you can also list your file formats available on your Asterisk with :
core show file formats

this is what I have on my installation
Format Name Extensions


slin mp3 mp3
h264 h264 h264
h263 h263 h263
g726 g726-16 g726-16
g726 g726-24 g726-24
g726 g726-32 g726-32
g726 g726-40 g726-40
slin ogg_vorbis ogg
g723 g723sf g723|g723sf
adpcm vox vox
gsm wav49 WAV|wav49
slin48 ogg_opus opus
ilbc iLBC ilbc
slin192 sln192 sln192
slin96 sln96 sln96
slin48 sln48 sln48
slin44 sln44 sln44
slin32 sln32 sln32
slin24 sln24 sln24
slin16 sln16 sln16
slin12 sln12 sln12
slin sln sln|raw
g719 g719 g719
siren14 siren14 siren14
siren7 siren7 siren7
g729 g729 g729
gsm gsm gsm
speex32 ogg_speex32 spx32
speex16 ogg_speex16 spx16
speex ogg_speex spx
g722 g722 g722
ulaw au au
alaw alaw alaw|al|alw
ulaw pcm pcm|ulaw|ul|mu|ulw
slin16 wav16 wav16
slin wav wav
36 file formats registered.

1 Like

exactly here is the solution :slight_smile:
thank you!
converted file into the correct format and used full path for the file:

sudo sox newname222.wav -r 8000 -c 1 -b 16 -e signed-integer /var/lib/asterisk/sounds/output_new.wav

ubuntu@21352:/var/lib/asterisk/sounds$ sox --i output_new.wav

Input File     : 'output_new.wav'
Channels       : 1
Sample Rate    : 8000
Precision      : 16-bit
Duration       : 00:00:04.99 = 39938 samples ~ 374.419 CDDA sectors
File Size      : 79.9k
Bit Rate       : 128k
Sample Encoding: 16-bit Signed Integer PCM

actually, where i can find requirements (bitrate, encoding, etc) for other formats, for example mp3?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.