|
|
@@ -15,6 +15,7 @@ import midware.service.rep.IOutPhoneService;
|
|
15
|
15
|
import midware.service.rep.IRecordService;
|
|
16
|
16
|
import midware.util.enums.EslAgentEnum;
|
|
17
|
17
|
import midware.util.enums.EslEventEnum;
|
|
|
18
|
+import midware.util.helper.AsyncHelper;
|
|
18
|
19
|
import midware.util.helper.RedisHelper;
|
|
19
|
20
|
import midware.util.helper.SpringHelper;
|
|
20
|
21
|
import midware.util.helper.StringHelper;
|
|
|
@@ -39,7 +40,7 @@ import java.util.stream.Collectors;
|
|
39
|
40
|
public class EslEventListener implements IEslEventListener {
|
|
40
|
41
|
@Override
|
|
41
|
42
|
public void eventReceived(EslEvent event) {
|
|
42
|
|
- //System.out.println(1 + "|" + JSON.toJSONString(event));
|
|
|
43
|
+ System.out.println(1 + "|" + JSON.toJSONString(event));
|
|
43
|
44
|
//log.warn(1 + "|" + JSON.toJSONString(event));
|
|
44
|
45
|
|
|
45
|
46
|
IConfigService iConfigService = SpringHelper.getBean(IConfigService.class);
|
|
|
@@ -120,7 +121,7 @@ public class EslEventListener implements IEslEventListener {
|
|
120
|
121
|
result.put("Type", "Wait");
|
|
121
|
122
|
result.put("Result", true);
|
|
122
|
123
|
result.put("Count", listWait.size());
|
|
123
|
|
- webSocketService.sendMessageGroupAll(queue,JSON.toJSONString(result));
|
|
|
124
|
+ webSocketService.sendMessageGroupAll(queue, JSON.toJSONString(result));
|
|
124
|
125
|
|
|
125
|
126
|
//播报位置
|
|
126
|
127
|
eslClientService.playPosition(listWait.indexOf(caller) + 1, uuid);
|
|
|
@@ -155,7 +156,7 @@ public class EslEventListener implements IEslEventListener {
|
|
155
|
156
|
result.put("Type", "Wait");
|
|
156
|
157
|
result.put("Result", true);
|
|
157
|
158
|
result.put("Count", EslCommon.groupWaitList.get(queue).size());
|
|
158
|
|
- webSocketService.sendMessageGroupAll(queue,JSON.toJSONString(result));
|
|
|
159
|
+ webSocketService.sendMessageGroupAll(queue, JSON.toJSONString(result));
|
|
159
|
160
|
}
|
|
160
|
161
|
}
|
|
161
|
162
|
//eslClientService.playAgent(header.get("CC-Agent"), header.get("CC-Member-Session-UUID"));
|
|
|
@@ -171,12 +172,26 @@ public class EslEventListener implements IEslEventListener {
|
|
171
|
172
|
result.put("Type", "Wait");
|
|
172
|
173
|
result.put("Result", true);
|
|
173
|
174
|
result.put("Count", EslCommon.groupWaitList.get(queue).size());
|
|
174
|
|
- webSocketService.sendMessageGroupAll(queue,JSON.toJSONString(result));
|
|
|
175
|
+ webSocketService.sendMessageGroupAll(queue, JSON.toJSONString(result));
|
|
175
|
176
|
}
|
|
176
|
177
|
}
|
|
177
|
178
|
break;
|
|
178
|
179
|
}
|
|
179
|
180
|
break;
|
|
|
181
|
+
|
|
|
182
|
+ case mod_funasr_json:
|
|
|
183
|
+ // 获取通道名称
|
|
|
184
|
+ String[] chanNames = header.get("Channel-Name").split("\\@")[0].split("\\/");
|
|
|
185
|
+ Channel chan2 = EslCommon.getChanByNumber(chanNames[2]);
|
|
|
186
|
+ String asrs = header.get("funasr_result").toString();
|
|
|
187
|
+ Map asr = JSON.parseObject(asrs, Map.class);
|
|
|
188
|
+ if (asr.containsKey("mode") && asr.get("mode").toString().equals("2pass-offline")) {
|
|
|
189
|
+ String text = asr.get("text").toString();
|
|
|
190
|
+ if (StringHelper.isNotEmpty(text)) {
|
|
|
191
|
+ sendAsr(chan2,text);
|
|
|
192
|
+ }
|
|
|
193
|
+ }
|
|
|
194
|
+ break;
|
|
180
|
195
|
}
|
|
181
|
196
|
} else {
|
|
182
|
197
|
// 获取会话ID
|
|
|
@@ -338,6 +353,16 @@ public class EslEventListener implements IEslEventListener {
|
|
338
|
353
|
result.put("Number", calleeNum);
|
|
339
|
354
|
webSocketService.sendMessage(callerAgent.getAgent(), JSON.toJSONString(result));
|
|
340
|
355
|
}
|
|
|
356
|
+ if(chanNames[2].equals(calleeNum)){
|
|
|
357
|
+ if (calleeAgent1 != null) {
|
|
|
358
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
359
|
+ result.put("Type", "Incoming");
|
|
|
360
|
+ result.put("Result", true);
|
|
|
361
|
+ result.put("CallID", chan.getRecordId());
|
|
|
362
|
+ result.put("Number", callerNum);
|
|
|
363
|
+ webSocketService.sendMessage(calleeAgent1.getAgent(), JSON.toJSONString(result));
|
|
|
364
|
+ }
|
|
|
365
|
+ }
|
|
341
|
366
|
} else {
|
|
342
|
367
|
chan.setRecordId(EslCommon.getChanByNumber(callerNum).getRecordId());
|
|
343
|
368
|
if (calleeAgent1 != null) {
|
|
|
@@ -502,8 +527,9 @@ public class EslEventListener implements IEslEventListener {
|
|
502
|
527
|
} else {
|
|
503
|
528
|
//是否开启语音识别
|
|
504
|
529
|
if (iConfigService.getConfigValue("EnableAsr").equals("1")) {
|
|
505
|
|
- eslClientService.appCommand(chanId, "set", "fire_asr_events=true");
|
|
506
|
|
- eslClientService.appCommand(chanId, "detect_speech", "unimrcp:mrcpv2 hello hello");
|
|
|
530
|
+ //eslClientService.appCommand(chanId, "set", "fire_asr_events=true");
|
|
|
531
|
+ //eslClientService.appCommand(chanId, "detect_speech", "unimrcp:mrcpv2 hello hello");
|
|
|
532
|
+ eslClientService.funasr(chanId);
|
|
507
|
533
|
}
|
|
508
|
534
|
}
|
|
509
|
535
|
}
|
|
|
@@ -531,6 +557,19 @@ public class EslEventListener implements IEslEventListener {
|
|
531
|
557
|
if (callerAgent != null && StringHelper.isNotEmpty(chan.getOpType())) {
|
|
532
|
558
|
actionNotice(chan.getOpType(), callerAgent.getAgent(), sid, false);
|
|
533
|
559
|
}
|
|
|
560
|
+ if (chan.getOpType().equals("Meeting")) {
|
|
|
561
|
+ List<Channel> channels = EslCommon.channels.stream().filter(p ->
|
|
|
562
|
+ p.getSessionId().equals(sid) && !p.getChanId().equals(chanId)).collect(Collectors.toList());
|
|
|
563
|
+ AsyncHelper.instance().execute(new TimerTask() {
|
|
|
564
|
+ @Override
|
|
|
565
|
+ public void run() {
|
|
|
566
|
+ for (Channel c : channels) {
|
|
|
567
|
+ eslClientService.playBreak(c.getChanId());
|
|
|
568
|
+ eslClientService.playBack("/home/website/midware/files/others/noanswer.mp3",c.getChanId());
|
|
|
569
|
+ }
|
|
|
570
|
+ }
|
|
|
571
|
+ });
|
|
|
572
|
+ }
|
|
534
|
573
|
}
|
|
535
|
574
|
|
|
536
|
575
|
boolean isupdate = true;
|
|
|
@@ -637,34 +676,7 @@ public class EslEventListener implements IEslEventListener {
|
|
637
|
676
|
String xml = String.join("", results);
|
|
638
|
677
|
xmlResult = getXmlResult(xml, true);
|
|
639
|
678
|
if (StringHelper.isNotEmpty(xmlResult)) {
|
|
640
|
|
- String csid = chan.getSessionId();
|
|
641
|
|
- List<Channel> channels = EslCommon.channels.stream().filter(p ->
|
|
642
|
|
- p.getSessionId().equals(csid) && p.getType() == 1).collect(Collectors.toList());
|
|
643
|
|
- for (Channel c : channels) {
|
|
644
|
|
- Agent agent1 = EslCommon.getAgentByExten(c.getNumber());
|
|
645
|
|
- if (agent1 != null) {
|
|
646
|
|
- Map<String, Object> result = new HashMap<>();
|
|
647
|
|
- result.put("Type", "Asr");
|
|
648
|
|
- result.put("Result", true);
|
|
649
|
|
- result.put("Speech", xmlResult);
|
|
650
|
|
- result.put("Number", chanNames[2]);
|
|
651
|
|
- webSocketService.sendMessage(agent1.getAgent(), JSON.toJSONString(result));
|
|
652
|
|
- }
|
|
653
|
|
- }
|
|
654
|
|
-
|
|
655
|
|
- Asr asr = new Asr();
|
|
656
|
|
- asr.setNumber(chanNames[2]);
|
|
657
|
|
- asr.setResult(xmlResult);
|
|
658
|
|
- asr.setUuid(csid);
|
|
659
|
|
- if (agent != null) {
|
|
660
|
|
- asr.setAgent(agent.getAgent());
|
|
661
|
|
- asr.setGroupNo(agent.getGroup());
|
|
662
|
|
- }
|
|
663
|
|
- asr.setCreateTime(new Date());
|
|
664
|
|
-
|
|
665
|
|
- synchronized (EslCommon.asrs) {
|
|
666
|
|
- EslCommon.asrs.add(asr);
|
|
667
|
|
- }
|
|
|
679
|
+ sendAsr(chan,xmlResult);
|
|
668
|
680
|
}
|
|
669
|
681
|
}
|
|
670
|
682
|
}
|
|
|
@@ -704,7 +716,7 @@ public class EslEventListener implements IEslEventListener {
|
|
704
|
716
|
|
|
705
|
717
|
@Override
|
|
706
|
718
|
public void backgroundJobResultReceived(EslEvent event) {
|
|
707
|
|
- //System.out.println(2 + "|" + JSON.toJSONString(event));
|
|
|
719
|
+ System.out.println(2 + "|" + JSON.toJSONString(event));
|
|
708
|
720
|
//log.warn(2 + "|" + JSON.toJSONString(event));
|
|
709
|
721
|
|
|
710
|
722
|
String bodys = event.getEventBodyLines().size() > 0 ? event.getEventBodyLines().get(0) : "";
|
|
|
@@ -830,4 +842,38 @@ public class EslEventListener implements IEslEventListener {
|
|
830
|
842
|
}
|
|
831
|
843
|
return result;
|
|
832
|
844
|
}
|
|
|
845
|
+
|
|
|
846
|
+ //发送识别结果
|
|
|
847
|
+ private void sendAsr(Channel chan,String text){
|
|
|
848
|
+ WebSocketService webSocketService = SpringHelper.getBean(WebSocketService.class);
|
|
|
849
|
+ String csid = chan.getSessionId();Agent agent=null;
|
|
|
850
|
+ List<Channel> channels = EslCommon.channels.stream().filter(p ->
|
|
|
851
|
+ p.getSessionId().equals(csid) && p.getType() == 1).collect(Collectors.toList());
|
|
|
852
|
+ for (Channel c : channels) {
|
|
|
853
|
+ Agent agent1 = EslCommon.getAgentByExten(c.getNumber());
|
|
|
854
|
+ if (agent1 != null) {
|
|
|
855
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
856
|
+ result.put("Type", "Asr");
|
|
|
857
|
+ result.put("Result", true);
|
|
|
858
|
+ result.put("Speech", text);
|
|
|
859
|
+ result.put("Number", chan.getNumber());
|
|
|
860
|
+ webSocketService.sendMessage(agent1.getAgent(), JSON.toJSONString(result));
|
|
|
861
|
+ if (c.getChanId().equals(chan.getChanId())) agent = agent1;
|
|
|
862
|
+ }
|
|
|
863
|
+ }
|
|
|
864
|
+
|
|
|
865
|
+ Asr asr = new Asr();
|
|
|
866
|
+ asr.setNumber(chan.getNumber());
|
|
|
867
|
+ asr.setResult(text);
|
|
|
868
|
+ asr.setUuid(csid);
|
|
|
869
|
+ if (agent != null) {
|
|
|
870
|
+ asr.setAgent(agent.getAgent());
|
|
|
871
|
+ asr.setGroupNo(agent.getGroup());
|
|
|
872
|
+ }
|
|
|
873
|
+ asr.setCreateTime(new Date());
|
|
|
874
|
+
|
|
|
875
|
+ synchronized (EslCommon.asrs) {
|
|
|
876
|
+ EslCommon.asrs.add(asr);
|
|
|
877
|
+ }
|
|
|
878
|
+ }
|
|
833
|
879
|
}
|