双腿识别,通过订阅事件获取识别结果
为了能实现双腿识别,这里通过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>