DP+MySQL: AMD-Answering Machine Detection

    版本為 03:28, 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)
    
    Powered by MindTouch Core