zaf / asterisk-googletts

Asterisk AGI script that uses Google's translate text to speech service.
GNU General Public License v2.0
214 stars 125 forks source link

Intkey digit number #43

Closed taphawane closed 1 year ago

taphawane commented 5 years ago

Hi Zaf My googletts is working great I have no issue with it. I am using for about for 5 years. Thanks you for time and great work well done!

Is there a way when you press a digit while the sound playing, to have a timeout, because I want to use the script to capture more than one digits, I am able to store one digit only just looking a way to capture more digit , like the READ() function in asterisk. Right now the script is running like a waitExten() This looking for possibilities, if there is any.

zaf commented 5 years ago

Hello,

the script handles playback here using STREAM FILE. As it is now it only works for single digits. I think your best chance is to edit the AGI script and modify the playback() sub to suit your needs.

taphawane commented 5 years ago

Hello,

I tried to edit the file, and located exactly where I need to edit. but I'm not familiar with way how the AGi is used in the file. The function i am use to are $agi->get_data(filename, timeout, maxdigit); which is php agi. in the cripte I don't know which function I replace with "$res = playback("$cachedir/$filename", $intkey);"

I know that I need to edit in these paragraph of line.

Stream file from cache if it exists

    if (-r "$cachedir/$filename.$fexten") {
        console_log("File already in cache.") if ($debug);
        $res = playback("$cachedir/$filename", $intkey);
        die  if ($res < 0);
        last if ($res > 0);
        next;

and

Playback and save file in cache

$res = playback($tmpname, $intkey);
die if ($res < 0);
if ($usecache) {
    console_log("Saving file $filename to cache") if ($debug);
    move("$tmpname.$fexten", "$cachedir/$filename.$fexten");
felipecrs commented 1 year ago

@zaf I'm really sorry to bring this again after all these years, but... is there any chance you can help me make the modifications needed to accept more than one digit? I'm playing with this for some hours already and I haven't got any far.

I'm using your AGI script to build a menu for my Home Assistant, in which I ask for a password in the very beginning. That's the reason why I want to accept more than one digit.

zaf commented 1 year ago

You don't really have to modify the script for that. Just write your dialplan in a way that plays the message and then waits for input from the user using for instance Read().

felipecrs commented 1 year ago

Thank you, that's what I was doing, but the problem is that by doing that I have to wait until the message is played before entering the number.

However I fixed it in another way. I ask the user to press 0 before entering the password, which then I initiate a Read(). It's working great!