Storing converted WAV voicemail greeting using ODBC

I’ve configured voicemail on Asterisk 13.9.1 to be stored as BLOB objects in a MySQL database and so far this works fine. My configuration is pretty simple and the table contains the standard columns.

[general]
format=wav49
odbcstorage=asterisk
odbctable=voicemail_messages
minsecs=2
maxgreet=60
fromstring=Voicemail Notifier
serveremail=noreply@domain.xx
emailsubject=New voicemail
emailbody=Some message

[voicemailcontext]
24268 => 24268,User1,user@domain.xx

However, as I’m trying to implement some default greeting for my users, I’m encountering some strange issues.

The first issue is that since I’m using ODBC, it appears that when I store a converted WAV in the user’s mailbox directory, it is played once when going to voicemail and then the file is automatically removed. Directory and file have user/group asterisk and are chmod-ed 770.

Before leaving a voicemail:

drwxrwx--- 2 asterisk asterisk   4096 May  8 15:34 INBOX
drwxrwx--- 2 asterisk asterisk   4096 May  8 15:34 Old
drwxrwx--- 2 asterisk asterisk   4096 May  8 16:06 tmp
-rwxrwx--- 1 asterisk asterisk 143544 May  8 19:36 unavail.wav
drwxrwx--- 2 asterisk asterisk   4096 May  8 15:34 Urgent

Just to make sure that the file was converted successfully (using sox):

file unavail.wav
unavail.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 8000 Hz

After single play of the greeting:

drwxrwx--- 2 asterisk asterisk 4096 May  8 19:39 INBOX
drwxrwx--- 2 asterisk asterisk 4096 May  8 15:34 Old
drwxrwx--- 2 asterisk asterisk 4096 May  8 19:39 tmp
drwxrwx--- 2 asterisk asterisk 4096 May  8 15:34 Urgent

Relevant Asterisk console:

<PJSIP/632780-00000000> Playing '/var/spool/asterisk/voicemail/voicemailcontext/24268/unavail.slin' (language 'nl')
<PJSIP/632780-00000000> Playing 'vm-intro.gsm' (language 'nl')
 <PJSIP/632780-00000000> Playing 'beep.gsm' (language 'nl')
Recording the message
 x=0, open writing:  /var/spool/asterisk/voicemail/voicemailcontext/24268/tmp/j0NyYI format: wav49, 0x7fe83c035378
User hung up
  == Parsing '/var/spool/asterisk/voicemail/voicemailcontext/24268/INBOX/msg0000.txt': Found
  == Parsing '/var/spool/asterisk/voicemail/voicemailcontext/24268/INBOX/msg0000.txt': Found
  == Parsing '/var/spool/asterisk/voicemail/voicemailcontext/24268/INBOX/msg0000.txt': Found
  == Parsing '/var/spool/asterisk/voicemail/voicemailcontext/24268/INBOX/msg0000.txt': Found

I suppose the file gets deleted because exclusively ODBC storage is used according to voicemail.conf? When I record the greeting manually, it gets stored in the voicemail table as a BLOB and plays every time I call the voicemail.

However, when I try to add a default greeting for every user, the greeting is skipped.

UPDATE voicemail_messages SET recording = LOAD_FILE(') WHERE ...

Relevent Asterisk console:

[May  8 19:50:26] WARNING[157674][C-00000001]: format_wav_gsm.c:116 check_header: Does not begin with RIFF
[May  8 19:50:26] WARNING[157674][C-00000001]: file.c:472 fn_wrapper: Unable to open format wav49
[May  8 19:50:26] WARNING[157674][C-00000001]: format_wav_gsm.c:116 check_header: Does not begin with RIFF
[May  8 19:50:26] WARNING[157674][C-00000001]: file.c:472 fn_wrapper: Unable to open format wav49
[May  8 19:50:26] WARNING[157674][C-00000001]: file.c:1100 ast_streamfile: Unable to open /var/spool/asterisk/voicemail/voicemailcontext/24268/unavail (format (alaw|ulaw)): No such file or directory
    -- <PJSIP/632780-00000001> Playing 'vm-intro.gsm' (language 'nl')
    -- <PJSIP/632780-00000001> Playing 'beep.gsm' (language 'nl')
    -- Recording the message
    -- x=0, open writing:  /var/spool/asterisk/voicemail/voicemailcontext/24268/tmp/aQnsbi format: wav49, 0x7fe93c014968
    -- User hung up

I’ve also seen Asterisk crash with some vague “Bus error”.

WAV details of the greeting I’m trying to insert as a record:.
unavail.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 8000 Hz

When I save the BLOB, the wav plays just fine on my computer.

Am I doing something wrong while converting the wav? This is the simple command I’m using:
sox unavailorig.wav -r 8000 -c 1 unavail.wav

1 Like

That’s how I convert my files too, so I don’t think that’s wrong. Is your Asterisk running as root or another user? If not root, might want to chown -R the /var/spool/asterisk/voicemail/ directory. That being said, I’m not sure if the wav file can be used with the gsm codec.

Asterisk is running as user “asterisk”. I’ve tried recursive chown for user/group asterisk and chmod 775 but that doesn’t seem to make a difference.

I suppose asterisk won’t use the gsm codec since I’ve defined format=wav49? However, it looks like voicemail messages itself are stored with the gsm codec (downloaded blob with Content-Type: audio/wav)
voicemail-300317-1517.wav: RIFF (little-endian) data, WAVE audio, GSM 6.10, mono 8000 Hz
Those file plays fine on my computer.

Therefor, I’ve also tried inserting the greeting with gsm codec applied to it:
sox unavailorig.wav -r 8000 -c 1 -e gsm-full-rate unavail.wav

I’ve found a solution.

Apparantly I needed to use a GSM-encoded wav49 when having format=wav49 in voicemail.conf.

Convert file:
sox unavailorig.wav -c 1 -r 8000 -e gsm-full-rate -t wav /tmp/unavail.wav

Working import to BLOB:
UPDATE voicemail_messages SET recording = LOAD_FILE('/tmp/unavail.wav') WHERE ...

1 Like