Can you batch upload system recordings

Hello, as a very new user, I very much appreciate all of the helpful information you have all provided in this forum which has helped me get started,

I am using FreePBX 16.0.39 with asterisk 18.16.0 and building an ARI app with nodejs and node-ari-client.

The short summary is that I am looking for a way to “import” hundreds of wav files as .system recordings, without having to create a new system recording in the GUI for each one. Even an explanation of what kind of archive may be uploaded to the system recordings would be helpful. The rest of this post are some details.

We are simulating a legacy IVR application and need to play hundreds of our existing wav files via FreePBX. From what I have seen in the wiki and sample applications, I have had success in using code like{media: ‘sound:custom/W9615’}, …
but only after using the GUI to create a new system recording, and uploading the file in the GUI. This would be tedious for hundreds of files, so I am looking for a more efficient way, perhaps one that used from the command line which could use to streamline the process of uploading new recordings by staff that are not FreePBX admins.

Copying a wav file to /var/lib/asterisk/sounds/en/custom will not enable me to play it with the “sound: custom/myFilewav” specification, and I have searched the files in /etc/asterisk and cannot see if there is some config file I could update, and might surmise that there is some internal database used by FreePBX which I cannot access – hence my attempts fail.

The Asterisk REST documentation at:
ARI and Channels: Simple Media Manipulation (sorry, as new user the system does not allow me to post URLs…)
states that one may use a URL for “sound” so I set up a python simpleHTTPServer and tried

sound: http://… (i am not beling allowed to type the whole URL here!)

but this did not work either.

The GUI and the wiki say you may upload an archive but I could not find details on this - a tar, a tgz, and a .zip attempt each failed as unsupported types.

Lastly, there is an old thread in this forum about uploading prompts as a new language:
But this is based on much older versions, and I could not see how to implement the suggestions in this, or discover how to set my own language in the ARI.

Of course, if there is a better way to use the function in the ARI which bypasses the system recordings modules, perhaps someone could point that out.

Thank you all in advance.

You should be able to drag and drop multiple files in a single System Recording. However, you may need to increase the PHP upload/memory limits so it doesn’t crash.

With that being said, you should be able to directly copy/scp the files to /var/lib/asterisk/sounds/en/custom or to /my/path and then use custom/file or /my/path/file in your dialplan or ARI app.

I assume that the reason why it only worked for you after uploading through the GUI, is because FreePBX converts the file to a format that your channel codec can play. So if that is the case, then you can convert the files using a third party tool (such as sox [1]), or use the built-in Asterisk file converter tool [2]

[1] Asterisk 10 Codecs and Audio Formats - Asterisk Project - Asterisk Project Wiki

[2] ow to convert WAV audio files for use un Asterisk

Thank you very much, PitzKey (nice name…) for your clear and exceptionally rapid response. I will experiment with this today. It sounds like this is what I am looking for.

1 Like

PitzKey, your diagnosis and advice was correct.
I was having difficulty using sox, so I first confirmed that placing properly encoded was files into en/custom enabled them to be played in the ARI, so I can now simply scp my converted files and bypass the GUI. Thank you.

Our original speech prompts were recorded on an ancient “bitworks” system for a dialogic based IVR, using ADPCM and what appears to be an odd configuration, since when they are converted to alaw with sox, they play a high pitch and speed. I can use “pitch -400” with sox, which corrects this, but there seems to be significant distortion of the kind one hears upon repeated compression/decompression. I hope I can find something in the archives which helps with this problem.

Thank you again for you valuable help.

If the FreePBX System Recording module converts it correctly, then look at the code how the conversion is done

Thank you.

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