DP+MySQL: AMD-Answering Machine Detection

    版本為 04:02, 27 Dec 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    AMD - 這是一個內建 Asterisk 的功能,可用來偵測接電話的對方是語音或人聲。

    Dialplan 範例

    [amd-test]
    exten => 9970,1,Noop(-- AMD Testing Start --)
     same => n,Background(beep)
     same => n,AMD()
     same => n,Noop(Detected: AMDSTATUS is ${AMDSTATUS})
     same => n,Goto(Status-${AMDSTATUS})
     same => n(Status-HUMAN),Noop(When AMDSTATUS  is <HUMAN>)
    same => n,
    WaitForSilence(2500)
    same => n,Playback(
    message-when-machine) same => n,Hangup same => n(Status-MACHINE),Noop(When AMDSTATUS is <MACHINE>)
    same => n,Hangup same => n(Status-NOTSURE),Noop(When AMDSTATUS is <NOTSURE>)
    same => n,Hangup  same => n(Status-HANGUP),Noop(When AMDSTATUS is <HANGUP>)
    same => n,Hangup
    amd.conf
    ;
    ; Answering Machine Detection Configuration
    ;
    
    [general]
    initial_silence = 2500          ; Maximum silence duration before the greeting.
                                    ; If exceeded then MACHINE.
    greeting = 1500                 ; Maximum length of a greeting. If exceeded then MACHINE.
    after_greeting_silence = 800    ; Silence after detecting a greeting.
                                    ; If exceeded then HUMAN
    total_analysis_time = 5000      ; Maximum time allowed for the algorithm to decide
                                    ; on a HUMAN or MACHINE
    min_word_length = 100           ; Minimum duration of Voice to considered as a word
    between_words_silence = 50      ; Minimum duration of silence after a word to consider
                                    ; the audio what follows as a new word
    maximum_number_of_words = 3     ; Maximum number of words in the greeting.
                                    ; If exceeded then MACHINE
    silence_threshold = 256   ;silence threshold is how loud silence is.
    

    Tips:

    • silence_threshold: 這是用來辨識silence的音量基準值,只要偵測到聲音低於這個值,就視為 silence。通常這個值僅可能的低,對於有些手機的用戶,因為手機的噪音會比較大,可能要稍微將它調高。

    範例:不需 amd.conf

    [amd-without-conf]
    exten => 7002,1,Answer()
    exten => 7002,n,AMD(2500,1500,300,5000,120,50,4,384)
    exten => 7002,n,GotoIf($["${AMDSTATUS}" = "MACHINE"]?machine:human)
    exten => 7002,n(machine),Verbose(3, We found an answring machine)
    exten => 7002,n,Set(AMP=${CALLERID(num)})
    exten => 7002,n,Set(date=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
    exten => 7002,n,NoOp(Here is the dialplan you want to run)
    exten => 7002,n(human),Verbose(3, We've got a human on the line!)
    exten => 7002,n,NoOp(Here is the dialplan you want to run)
    

    客戶的範例:

    [test-amd]
    exten => 9991,1,NoCDR()
    exten => 9991,n,Macro(amd-detection)
    exten => 9991,n,Playback(demo-echotest)
    exten => 9991,n,Echo()
    exten => 9991,n,Playback(demo-echodone)
    exten => 9991,n,Hangup
    exten => h,1,Noop(Logging the Call details into the DB)
    exten => h,n,Noop(AMDSTATUS: ${AMDSTATUS}, AMDCAUSE: ${AMDCAUSE})
    exten => h,n,Noop(UNIQUEID: ${UNIQUEID}, CALLDATE: ${CALLDATE})
    exten => h,n,MYSQL(Connect connid localhost root 123456 dialer)
    exten => h,n,MYSQL(Query resultid ${connid} INSERT INTO `amd_log`(`calldate`,`uniqueid`,`amd_status`,`amd_cause`) VALUES ('${CALLDATE}','${UNIQUEID}','${AMDSTATUS}','${AMDCAUSE}'))
    exten => h,n,MYSQL(Disconnect ${connid})
    
    
    [macro-amd-detection]
    exten => s,1,Noop(Answering Machine Detection - AMD)
    exten => s,n,Set(CALLDATE=${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)})
    exten => s,n,Background(beep)
    ; Syntax: AMD([initialSilence][,greeting[,afterGreetingSilence[,totalAnalysis Time[,miniumWordLength  [,betweenWordSilence[,maximumNumberOfWords[,silenceThreshold[,maximumWordLength]]]]]]]])
    exten => s,n,AMD(2500,1500,800,5000,120,50,4,256)
    exten => s,n,Noop(AMDSTATUS: ${AMDSTATUS}, AMDCAUSE: ${AMDCAUSE})
    exten => s,n,Noop(UNIQUEID: ${UNIQUEID}, CALLDATE: ${CALLDATE})
    exten => s,n,GotoIf($["${AMDSTATUS}" = "MACHINE"]?machine:human)
    exten => s,n(machine),Noop(We found an answering machine)
    exten => s,n,Hangup
    exten => s,n(human),Noop(We've got a human on the line)
    

    加強版: 將 AMD 變數寫入資料庫

    [dialerConnect]
    exten => _X.,1,NoCDR()
    exten => _X.,n,Set(CUSTOMER=${CUT(EXTEN,A,4)})
    exten => _X.,n,Set(CONTACTID=${CUT(EXTEN,A,3)})
    exten => _X.,n,Set(MEXTEN=${CUT(EXTEN,A,2)})
    exten => _X.,n,Set(IDCAMPAIGN=${CUT(EXTEN,A,1)})
    exten => _X.,n,Set(CALLERID(num)=${MEXTEN})
    exten => _X.,n,Set(CALLERID(name)=${MEXTEN})
    exten => _X.,n,MYSQL(Connect connid localhost root 123456 dialer)
    exten => _X.,n,MYSQL(Query resultid ${connid} select use_amd from settings)
    exten => _X.,n,MYSQL(Fetch foundRow ${resultid} useamd)
    exten => _X.,n,MYSQL(Clear ${resultid})
    exten => _X.,n,MYSQL(Disconnect ${connid})
    exten => _X.,n,GotoIf($["${USEAMD}" = "1"]?useamd:noamd)
    exten => _X.,n(useamd),Macro(amd-detection)
    exten => _X.,n,GotoIf($["${AMDSTATUS}" = "HUMAN"]?noamd:nhuman)
    exten => _X.,n(nhuman),GotoIf($["${AMDSTATUS}" = "MACHINE"]?hangup:nmachine)
    exten => _X.,n(nmachine),GotoIf($["${AMDSTATUS}" = "NOTSURE"]?notsure:hangup)
    exten => _X.,n(notsure),MYSQL(Connect connid localhost root 123456 dialer)
    exten => _X.,n,MYSQL(Query resultid ${connid} select amd_hangupifnotsure from settings)
    exten => _X.,n,MYSQL(Fetch foundRow ${resultid} acnotsure)
    exten => _X.,n,MYSQL(Clear ${resultid})
    exten => _X.,n,MYSQL(Disconnect ${connid})
    exten => _X.,n,GotoIf($["${ACNOTSURE}" = "1"]?hangup:noamd)
    exten => _X.,n(noamd),AGI(dialer.php,update,${IDCAMPAIGN},${CONTACTID},${UNIQUEID})
    exten => _X.,n,Queue(${IDCAMPAIGN})
    exten => _X.,n,Noop(QUEUESTATUS:${IDCAMPAIGN})
    exten => _X.,n(hangup),AGI(dialer.php,amdstatus,${AMDSTATUS},${CONTACTID},${MEXTEN})
    exten => _X.,n,HangUp()
    exten => h,n,MYSQL(Connect connid localhost root 123456 dialer)
    exten => h,n,MYSQL(Query resultid ${connid} update call_log set amd_status = '${AMDSTATUS}' where customer = '${CUSTOMER}' and campaign_id = '${IDCAMPAIGN}' and contact_id = '${CONTACTID}')
    exten => h,n,MYSQL(Disconnect ${connid})
    exten => h,n,AGI(dialer.php,queue,${MEXTEN},${UNIQUEID},${IDCAMPAIGN},${CONTACTID}) ; Só atualiza o Agent da chamada
    
     [macro-amd-detection]
    exten => s,1,Noop(Answering Machine Detection - AMD)
    exten => s,n,MYSQL(Connect connid localhost root 123456 dialer)
    exten => s,n,MYSQL(Query resultid ${connid} SELECT amd_initialSilence, amd_greeting, amd_afterGreetingSilence, amd_totalAnalysis, amd_miniumWordLength, amd_betweenWordSilence, amd_maximumNumberOfWords, amd_silenceThreshold from settings)
    exten => s,n,MYSQL(Fetch foundRow ${resultid} amd_initialSilence amd_greeting amd_afterGreetingSilence amd_totalAnalysis amd_miniumWordLength amd_betweenWordSilence amd_maximumNumberOfWords amd_silenceThreshold)
    exten => s,n,MYSQL(Clear ${resultid})
    exten => s,n,MYSQL(Disconnect ${connid})
    exten => s,n,Set(CALLDATE=${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)})
    ;exten => s,n,Background(beep)
    exten => s,n,AMD(${amd_initialSilence}, ${amd_greeting}, ${amd_afterGreetingSilence}, ${amd_totalAnalysis}, ${amd_miniumWordLength}, ${amd_betweenWordSilence}, ${amd_maximumNumberOfWords}, ${amd_silenceThreshold})
    Powered by MindTouch Core