Playing multiple files to users based on an API response as alternative to TTS Engine

Hi Everyone,
I don’t have much experience with FreePBX nor with programming.
I have a dynamic route that calls a URL and gets some information about the user’s phone number, such as balance, expiry, and some other details. and I want to be able to play the user’s balance and expiry date to the user.
I have Amazon Polly as TTS Engine for English and Arabic, yet, Kurdish is not supported in the TTS Engines.
I have the recordings for numbers and other words in separate files to be played to the users.

What is the best way to achieve that?

UPDATE:
I just created an AGI script and I can read the announcements the way I want it, but, is there any other better way to do it ?
my script is like below, it still need some modification so that I use the returned values from the API, but below is just the concept.


#!/usr/bin/php -q
<?php
require_once "phpagi.php";

$AGI = new AGI();
debug("TTS AGI Started", 1);

$files = [
    'en/custom/One',       
    'en/custom/Thousand',
    'en/custom/and',
    'en/custom/One'
];

// Play each file in sequence
foreach ($files as $file) {
    $AGI->stream_file($file, '#');
}

debug("TTS AGI end", 1);

function debug($string, $level=3) {
    global $AGI;
    $AGI->verbose($string, $level);
}
?>

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