雙腿識別,通過訂閱事件獲取識別結果
為了能實現雙腿識別,這里通過Lua腳本使用freeswitch.Session來實現,call.lue放在freeswitch的script目錄下
-- call.lua
session:answer();
local caller_number = argv[1]; --主叫號碼
local called_number = argv[2]; --被叫號碼
local dest = "{ignore_early_media=false,bridge_early_media=true,origination_caller_id_number=caller,origination_caller_id_name=8888,call_timeout=120}user/"..called_number.."";
session2 = freeswitch.Session(dest);
-- hello為語法文件名稱
session:execute("detect_speech", "unimrcp {sid=5657}hello default")
session2:execute("detect_speech", "unimrcp {sid=5657}hello default")
freeswitch.bridge(session, session2);
注:其中{sid=*}表示要傳給mrcp的參數,即GENERIC_HEADER_VENDOR_SPECIFIC_PARAMS 參考地址:unimrcp-recognize-headers
配置撥號計划
<extension name="test">
<condition field="destination_number" expression="^(1.*)$">
<action application="set" data="call_timeout=60"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="set" data="continue_on_fail=true"/>
<action application="export" data="bridge_answer_timeout=60"/>
<action application="set" data="called_number=$1"/>
<action application="lua" data="call.lua ${caller_id_number} ${called_number}"/>
</condition>
</extension>
