拨号计划:
<extension name="auto1"> <condition field="destination_number" expression="^(4001)$"> <action application="set" data="robotring=${sounds_dir}/musics/萨克斯-回家-铃声.wav"/> <action application="set" data="called_number=$1"/> <action application="set" data="call_uuid=${uuid}"/> <action application="lua" data="call_robot.lua ${caller_id_number} ${called_number} ${call_uuid} ${robotring}"/> </condition> </extension>
cat ../../scripts/call_robot.lua -- call_robot.lua session:answer(); local caller_number = argv[1]; --主叫号码 local called_number = argv[2]; --被叫号码 local robotring = argv[3]; --通话的唯一标识 math.randomseed(tostring(os.time()):reverse():sub(1,7)) local callUserId = math.random(100000000000) --time local begintime = os.date("%Y%m%d%H%M%S") ; -- 播放音频 -- session:streamFile(robotring); if (session:ready()) then -- Line is live, start talking -- session:flushDigits(); session:execute("detect_speech", "unimrcp {sid="..callUserId..",caller_number="..caller_number..",called_number="..called_number..",begintime="..begintime..",role=0}hello default") session:execute( "playback" , "robot.wav"); end session:hangup()
能通话30s左右,有识别,但是播放音频有问题