用户挂断时录制的文件丢失

时间:2016-08-18 15:48:59

标签: php file asterisk record agi

我正在编写一个语音应用程序,我想在其中保存录制的声音文件。 我的代码是:

$file = $clientid.rand(5, 10);
$agi->stream_file("itc-Por-favor-indique-su-nombre-numero-de-telefono");
$sal = $agi->record_file($file,"WAV","0123456789#*",-1,NULL,true); 

if ($sal['result'] > 0) {
    $bodytext = "Reclamo de la mesa de ayuda, cliente no identificado por IVR. 
\nNumero de Telefono: ".$agi->request['agi_callerid'];
}

每当我在录制过程中挂断时,录制应用程序无法执行并挂断电话。

有人知道如何在挂断时管理此记录功能吗?

1 个答案:

答案 0 :(得分:0)

你需要使用' k'用于指示星号的选项,您希望在挂起时保存文件而不进行确认。

core show application Record 

  -= Info about application 'Record' =- 

[Synopsis]
Record to a file. 

[Description]
If filename contains '%d', these characters will be replaced with a number
incremented by one each time the file is recorded. Use 'core show file formats'
to see the available formats on your system User can press '#' to terminate the
recording and continue to the next priority. If the user hangs up during a
recording, all data will be lost and the application will terminate.
${RECORDED_FILE}: Will be set to the final filename of the recording.
${RECORD_STATUS}: This is the final status of the command
    DTMF:A terminating DTMF was received ('#' or '*', depending upon option
    't')
    SILENCE:The maximum silence occurred in the recording.
    SKIP:The line was not yet answered and the 's' option was specified.
    TIMEOUT:The maximum length was reached.
    HANGUP:The channel was hung up.
    ERROR:An unrecoverable error occurred, which resulted in a WARNING to the
    logs.

[Syntax]
Record(filename.format[,silence[,maxduration[,options]]])

[Arguments]
format
    Is the format of the file type to be recorded (wav, gsm, etc).
silence
    Is the number of seconds of silence to allow before returning.
maxduration
    Is the maximum recording duration in seconds. If missing or 0 there is no
    maximum.
options
    a: Append to existing recording rather than replacing.

    n: Do not answer, but record anyway if line not yet answered.

    q: quiet (do not play a beep tone).

    s: skip recording if the line is not yet answered.

    t: use alternate '*' terminator key (DTMF) instead of default '#'

    x: Ignore all terminator keys (DTMF) and keep recording until hangup.

    k: Keep recorded file upon hangup.

    y: Terminate recording if *any* DTMF digit is received.