Asterisk not picking up my sound file

Folks,

I have been running an older version of Asterisk for the past three years. Never had to touch it.

Now, I am building a new Ubuntu box with the latest version of Asterisk.

In my extensions.conf, I have the following line:

exten => s,4,Background(MY/mainmenuannounce)

I also created a directory “MY” under /var/lib/asterisk/sounds and copied mainmenuannounce.gsm to that directory.

I also ensured that /var/lib/asterisk/sounds/MY and the file under it has asterisK:asterisk as the owner.

However, when I call in, I see that Asterisk is not able to locate my file:

file.c:650 ast_openstream_full: File MY/mainmenuannounce does on exist in any format
file.c:953 ast)streamfile; Unable to open MY/mainmenuannounce (format 0x4 (ulaw): No such file or directory

This setup is similar to what I had with my previous installation. I don’t understand what has changed.

I would appreciate your help in identifying my problem.

Thank you in advance for your help.

Regards,
Peter

PS: Another interesting thing that I found is that asterisk plays vm-goodbye.gsm at the end. This file plays fine although
there is no such file under /var/lib/asterisk/sounds. Upon searching from the root, I found only one occurrence of vm-goodbye.gsm. This was under /usr/share/asterisk/sounds/en_US_f_Allison directory. Command “grep -i Allison /etc/asterisk/*conf” does not return any reference. Strange.

under sounds is languages directories. en = english, fr = french, es = spanish
put your MY under the en directory.

atleast this is what I do under 1.6.2. I haven’t yet looked to see if the layout is different under 1.8.

I’ll tell something about vm-goodbye.

Playing of this file is hardwritten in source code. To get rid of it I had to modify sources (I’ve found it the only correct decision).
It’s probably in app_voicemail.c source file (if you’re interested).

p.s. We’re using now asterisk 1.4.21.1)

I am having this same issue running Asterisk 1.6.2.7 on Ubuntu Server 10.04 LTS. When I looked in /var/lib/asterisk/sounds, the only thing that existed was an empty directory called custom. So I created the ‘en’ directory for english, downloaded the asterisk sounds from the downloads page on asterisk.org and added them to the en directory. Still no joy.

I am still getting…

[Aug 4 13:27:24] WARNING[11537]: file.c:650 ast_openstream_full: File press-1 does not exist in any format [Aug 4 13:27:24] WARNING[11537]: file.c:953 ast_streamfile: Unable to open press-1 (format 0x4 (ulaw)): No such file or directory

Ubuntu users seem to have a lot of problems with the packages. Given that they seem to have been built non-root, are they actually maintained as part of Asterisk, or should you be getting support from Ubuntu? (Asterisk is not very comfortable running non-root and I think most technical users don’t try.)

In terms of the search, maybe there is a symbolic link to the Alison directory?

This seems like a fairly simple file location issue.

I have this code in my extensions.conf

[code][demo-menu]
exten => s,1,Answer(500)
same => n(loop),Background(press-1&or&press-2)
same => n,WaitExten()

exten => 1,1,Playback(you-entered)
same => n,SayNumber(1)
same => n,Goto(s,loop)

exten => 2,1,Playback(you-entered)
same => n,SayNumber(2)
same => n,Goto(s,loop)
[/code]

From my research, this file should be located in /var/lib/asterisk/sounds/en. The error, among others, is…

Now in /var/lib/asterisk/sounds/en, exists the following file…

-rw-r–r-- 1 asterisk asterisk 7360 2011-08-04 13:23 press-1.ulaw

So,in theory, this should work. However I am making two assumptions here.

  1. Asterisk is trying to pull these files from /var/lib/asterisk/sounds/en as the user, asterisk.
  2. Asterisk is trying to pull a file named press-1.ulaw

How can I confirm these two assumptions?

you could always code the full path to a sound file to make sure it can get there and play it…

exten => 1003,1,Answer
exten => 1003,n,Playback(/var/lib/asterisk/sounds/en/you-seem-impatient)
exten => 1003,n,Hangup

from the console a: core show settings might be helpful. It would show where a number of your directories are pointed to, in the event that they are not the defaults.

I haven’t looked into the code yet for playback to see what it uses as its base directory, but I would suspect its the astvarlibdir setting.

And check the user rights for the /var/lib/asterisk/sounds/en/. I think that Ubuntu package is made so the Asterisk is ran by a non-root user, so that user should have access to the sound files.

[quote=“mazzic”]you could always code the full path to a sound file to make sure it can get there and play it…

exten => 1003,1,Answer
exten => 1003,n,Playback(/var/lib/asterisk/sounds/en/you-seem-impatient)
exten => 1003,n,Hangup
[/quote]

Ok that helped. We are getting closer now. Here is what my extensions.conf looks like now…

[code][demo-menu]
exten => s,1,Answer(500)
same => n(loop),Background(/var/lib/asterisk/sounds/en/press-1&or&/var/lib/asterisk$
same => n,WaitExten()

exten => 1,1,Playback(/var/lib/asterisk/sounds/en/you-entered)
same => n,SayNumber(1)
same => n,Goto(s,loop)

exten => 2,1,Playback(/var/lib/asterisk/sounds/en/you-entered)
same => n,SayNumber(2)
same => n,Goto(s,loop)
[/code]

Here are the errors that I am seeing in CLI.

== Using SIP RTP CoS mark 5 -- Executing [3001@users:1] Goto("SIP/adam-00000007", "demo-menu,s,1") in new stack -- Goto (demo-menu,s,1) -- Executing [s@demo-menu:1] Answer("SIP/adam-00000007", "500") in new stack -- Executing [s@demo-menu:2] BackGround("SIP/adam-00000007", "/var/lib/asterisk/sounds/en/press-1&or&/var/lib/asterisk/sounds/en/press-2") in new stack -- <SIP/adam-00000007> Playing '/var/lib/asterisk/sounds/en/press-1.ulaw' (language 'en') [Aug 5 09:19:47] WARNING[12040]: file.c:650 ast_openstream_full: File or does not exist in any format [Aug 5 09:19:47] WARNING[12040]: file.c:953 ast_streamfile: Unable to open or (format 0x4 (ulaw)): No such file or directory [Aug 5 09:19:47] WARNING[12040]: pbx.c:8860 pbx_builtin_background: ast_streamfile failed on SIP/adam-00000007 for /var/lib/asterisk/sounds/en/press-1&or&/var/lib/asterisk/sounds/en/press-2 -- Executing [s@demo-menu:3] WaitExten("SIP/adam-00000007", "") in new stack == CDR updated on SIP/adam-00000007 -- Executing [1@demo-menu:1] Playback("SIP/adam-00000007", "you-entered") in new stack [Aug 5 09:19:54] WARNING[12040]: file.c:650 ast_openstream_full: File you-entered does not exist in any format [Aug 5 09:19:54] WARNING[12040]: file.c:953 ast_streamfile: Unable to open you-entered (format 0x4 (ulaw)): No such file or directory [Aug 5 09:19:54] WARNING[12040]: app_playback.c:471 playback_exec: ast_streamfile failed on SIP/adam-00000007 for you-entered -- Executing [1@demo-menu:2] SayNumber("SIP/adam-00000007", "1") in new stack -- <SIP/adam-00000007> Playing 'digits/1.gsm' (language 'en') -- Executing [1@demo-menu:3] Goto("SIP/adam-00000007", "s,loop") in new stack -- Goto (demo-menu,s,2) -- Executing [s@demo-menu:2] BackGround("SIP/adam-00000007", "/var/lib/asterisk/sounds/en/press-1&or&/var/lib/asterisk/sounds/en/press-2") in new stack -- <SIP/adam-00000007> Playing '/var/lib/asterisk/sounds/en/press-1.ulaw' (language 'en') [Aug 5 09:19:55] WARNING[12040]: file.c:650 ast_openstream_full: File or does not exist in any format [Aug 5 09:19:55] WARNING[12040]: file.c:953 ast_streamfile: Unable to open or (format 0x4 (ulaw)): No such file or directory [Aug 5 09:19:55] WARNING[12040]: pbx.c:8860 pbx_builtin_background: ast_streamfile failed on SIP/adam-00000007 for /var/lib/asterisk/sounds/en/press-1&or&/var/lib/asterisk/sounds/en/press-2 -- Executing [s@demo-menu:3] WaitExten("SIP/adam-00000007", "") in new stack == Spawn extension (demo-menu, s, 3) exited non-zero on 'SIP/adam-00000007'

The press-1 sound is playing. I am not sure why the rest of them are not playing. I am going to back double-check the file names but if you see anything else in here, let me know.

in this case the error is caused because you didn’t put the directory path on the “or” file.

   same => n(loop),Background(/var/lib/asterisk/sounds/en/press-1&or&/var/lib/asterisk/sounds/en/press-2)

not the preferred solution you would need the path on all 3 files…

   same => n(loop),Background(/var/lib/asterisk/sounds/en/press-1&/var/lib/asterisk/sounds/en/or&/var/lib/asterisk/sounds/en/press-2)

The Playback (and I would assume Background) application use the astdatadir variable for the base path to the sounds. Do you define this in your asterisk.conf file? if so were is it pointing to ? if its not defined try adding:

asterisk.conf

astdatadir => /var/lib/asterisk

will probably need to restart asterisk to take effect. Then try your playback without the added path info.

For further reference:
Debian and Ubuntu packages create symlinks in /var/lib/asterisk/sounds as root. Chown them to your asterisk-user and everything is working, including foreign languages (if correctly installed)

Ubuntu Asterisk Package does not honor asterisk.cfg astdatadir

root:/usr/share/asterisk# rasterisk -x ‘core show settings’ |grep “Data directory” Data directory: /usr/share/asterisk

root:/usr/share/asterisk# grep astdata /etc/asterisk/asterisk.conf
astdatadir => /var/lib/asterisk

So you have to place your sounds at /usr/share/asterisk/sounds or make symbolic links there,

root@CPX-0D0U9869N4N:/usr/share/asterisk/sounds# ls -l
total 0
lrwxrwxrwx 1 root root 36 Feb 28 2018 custom -> …/…/…/local/share/asterisk/sounds
lrwxrwxrwx 1 root root 36 May 31 09:52 en -> /etc/alternatives/asterisk-prompt-en
lrwxrwxrwx 1 root root 39 May 31 09:52 en_US -> /etc/alternatives/asterisk-prompt-en-us
drwxr-xr-x 1 root root 4096 May 31 09:51 en_US_f_Allison
lrwxrwxrwx 1 root root 27 Jun 1 09:19 es -> /var/lib/asterisk/sounds/es
lrwxrwxrwx 1 root root 35 Feb 28 2018 priv-callerintros -> /var/lib/asterisk/priv-callerintros
lrwxrwxrwx 1 root root 31 Feb 28 2018 recordings -> /var/lib/asterisk/sounds/custom