Mass upload sound files into FreePBX



  • @JaredBusch said in Convert Asterisk dial plan for use in FreePBX:

    The announcement links to a sound recording by id number. So that means the recordings need to be added first and a subquery put into the SQL statement to look it up.

    This should be straightforward assuming that names are matched up.
    Sounds can be uploaded with SCP and potentially inserted into MySQL.

    Upload your sound files to the defualt location

    This example is specifically using the root user. If you do not use root, adjust appropriately.

    scp *.wav [email protected]:/var/lib/asterisk/sounds/en/custom
    

    Log in to FreePBX with SSH (assuming as root) to fix permisisons

    # Set the ownership of the files and their permissions
    chown asterisk:asterisk /var/lib/asterisk/sounds/en/custom/*
    chmod 644 /var/lib/asterisk/sounds/en/custom/*
    

    If desired you can convert the file formats

    Converting to ulaw is useful because generally, calls are using ulaw and thus the PBX will not have to do any transcoding when playing a sound file to a caller.
    It is defintely not required because converting from a normal wav to ulaw is extremely fast and take little processor. but it is still a conversion.

    asterisk -x "file convert en/custom/filename1.wav en/custom/filename1.ulaw"
    asterisk -x "file convert en/custom/filename2.wav en/custom/filename2.ulaw"
    

    Now you need to insert a MySQL record for each sound file into the recordings table

    # Assuming you are in as the root user, you can get into MySQL without a password
    mysql asterisk
    insert into recordings (displayname,filename,description,fcode,fcode_pass) values ('recording_1_name','custom/filename1','Recording 1 Name',0,'');
    insert into recordings (displayname,filename,description,fcode,fcode_pass) values ('recording_2_name','custom/filename2','Recording 2 Name',0,'');
    exit
    

    Reload FreePBX

    fwconsole reload
    

    Notes about the SQL statement:
    displayname cannot have spaces
    filename has to match case sensitive to the filename that you uploaded
    description is a normal text entry
    fcode is Feature Code. This is advanced, just don't touch.
    fcode_pass is the passcode for the Feature Code. Leave as empty string.



  • You really want your Display Name to be descriptive. Because that is what is used in the IVR menu for selecting recordings

    24e8c971-bd93-42d9-a59b-e90fcda4b9a3-image.png



  • Very useful stuff, thanks for this.



  • @NashBrydges said in Mass upload sound files into FreePBX:

    Very useful stuff, thanks for this.

    Self serving. I’m buildinging a mass import right now using this process.