如何将$ agi-> get_data与多个音频文件一起使用

时间:2019-05-15 09:21:58

标签: php asterisk agi phpagi

在“背景播放”,“阅读”中,我们可以将音频文件与&组合在一起,例如file1&file2
在PHPAgi中,我使用$agi->get_data而不是Read,但是看起来只接受一个文件!

我还尝试在调用get_data之前使用Background播放音频:

$multipleAudioPath = 'file1&file2';
$agi->exec('Background', $multipleAudioPath);
$rawInput = $agi->get_data('blankAudioFile', $timeout, $digits);

但是第一个字符用于破坏背景音频,并且没有陷入get_data中。

我该怎么办?我可以单独使用$agi->get_data吗?还是有其他解决方案?

2 个答案:

答案 0 :(得分:0)

您可以使用“读取星号”命令使用多个文件。

$agi->exec("Read","variable,filename&filename2")

[Syntax]
Read(variable[,filename[&filename2[&...]][,maxdigits[,options[,attempts[,timeout]]]]])

[Arguments]
variable
    The input digits will be stored in the given <variable> name.
filename
    file(s) to play before reading digits or tone with option i
maxdigits
    Maximum acceptable number of digits. Stops reading after <maxdigits> have
    been entered (without requiring the user to press the '#' key).
    Defaults to '0' - no limit - wait for the user press the '#' key. Any value
    below '0' means the same. Max accepted value is '255'.
options
    s: to return immediately if the line is not up.

    i: to play  filename as an indication tone from your "indications.conf".

    n: to read digits even if the line is not up.

attempts
    If greater than '1', that many <attempts> will be made in the event no data
    is entered.
timeout
    The number of seconds to wait for a digit response. If greater than '0',
    that value will override the default timeout. Can be floating point.

[See Also]
SendDTMF()

其他选项是通过SOX或通过libsox将其混合在一起。

答案 1 :(得分:-1)

您可以使用以下代码

$input = '';
$agi->fastpass_get_data($input,"file1", null, 1);
$agi->fastpass_get_data($input,"file2", null, 1);
$agi->fastpass_get_data($input,'beep', 5000, 1);