Add MP3 Support in FreePBX

I have a FreePBX server that I have installed a script that needs to convert a file from MP3 to wav but I’m getting an error that there is no MP3 support for free PBX how do I add MP3 support I have tried a few commands but get an error that command is not found.

What does the script call to encode mp3’s ?

Here is part of the script.

echo “Building TTS file…”;
echo chr(13).chr(10);

$msg = file_get_contents($tmptext);
echo chr(13).chr(10);

$ch = curl_init();

$URL = “$IBM_url” . “/v1/synthesize?voice=” . “$IBM_voice” ;

curl_setopt($ch, CURLOPT_URL, “$URL”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, “{"text":"$msg"}”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, “$IBM_username” . “:” . “$IBM_password”);

$headers = array();
$headers[] = “Content-Type: application/json”;
$headers[] = “Accept: audio/mp3”;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo ‘Error:’ . curl_error($ch);

unlink (“/tmp/weather.wav”) ;
$fp = fopen(“/tmp/weather.mp3”, “w”);
curl_close ($ch);

shell_exec(“/usr/bin/sox /tmp/weather.mp3 -r 8000 -c 1 /tmp/weather.wav”);

unlink (“/tmp/weather.mp3”) ;


Where are you getting errors or being told there is no mp3 support? What are you doing in FreePBX that tells you this?

When I run the script I get this error. /usr/bin/sox FAIL formats: no handler for file extension `mp3’

Because sox doesn’t have mp3 support by default. You need to install the mp3 library. Try yum install libsox-fmt-mp3 or apt install depending on the OS.

when I run yum install libsox-fmt-mp3 I get

Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
No package libsox-fmt-mp3 available.
Error: Nothing to do

This might offer some clues:

Is there a different command I need to run to install MP3 support?

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