Kaynağa Gözat

实时语音转义代码提交

miaofuhao 2 yıl önce
ebeveyn
işleme
64b3b827e7

+ 1 - 0
WebUI/CallCenterWeb.UI/Script/Common/huayi.config.js

@@ -6,6 +6,7 @@ huayi.config = {
6 6
 //	callcenter_url: "http://docking.zwfw.anyang.gov.cn:9998/",//生产环境
7 7
 	//videoSocket_ip: "docking.zwfw.anyang.gov.cn", //docking.zwfw.anyang.gov.cn
8 8
 	//videoSocket_port: "8082", //端口
9
+	translation_socket:"ws://222.143.106.46:12233",
9 10
     socket_ip: "192.168.8.7", //ip
10 11
     socket_port: "8081", //端口
11 12
     menuworktime: 30000, //菜单工单数量刷新间隔

+ 3 - 3
WebUI/CallCenterWeb.UI/TelCall/uplinkSMSList.html

@@ -112,9 +112,9 @@
112 112
 				}
113 113
 			})
114 114
 			function dispose(val,row){
115
-
115
+				
116 116
         		if (!row.F_Name) {
117
-	               return '<a class="xg" onclick="addWorkOrder(\''+val+'\',\''+row.CallerNum+'\',\''+row.Content+'\')" title="添加工单">添加工单</a>';
117
+	               return '<a class="xg" onclick="addWorkOrder(\''+val+'\',\''+row.CallerNum+'\',\''+encodeURI(row.Content)+'\')" title="添加工单">添加工单</a>';
118 118
 	            } else {
119 119
 	                return '<a class="xg" onclick="ckxq(\'' + row.F_Name + '\')" title="点击查看工单详情">' + row.F_Name + '</a>';
120 120
 	            }
@@ -132,7 +132,7 @@
132 132
 	        	if (str) {
133 133
 	            	layer.open({
134 134
 	                    type: 2,
135
-	                    content: "../Appeal/AddAppeal.html?SMSID=" + str+"&callerNum="+callerNum+"&incomingContect="+encodeURI(content) , //iframe的url,no代表不显示滚动条
135
+	                    content: "../Appeal/AddAppeal.html?SMSID=" + str+"&callerNum="+callerNum+"&incomingContect="+content , //iframe的url,no代表不显示滚动条
136 136
 	                    title: '工单详情',
137 137
 	                    area: ['100%', '100%'], //宽高
138 138
 	                });

+ 7 - 23
WebUI/CallCenterWeb.UI/home.html

@@ -1229,42 +1229,26 @@
1229 1229
 				</li>
1230 1230
 			</ul>
1231 1231
 		</div>
1232
-		<div id="clickElementVoice" style="display: none;">展开</div>
1232
+		<div id="clickElementVoice">展开</div>
1233 1233
 		<div class="voiceToText" style="display: none;">
1234 1234
 			<div class="voiceToTextTitle">坐席辅助</div>
1235 1235
 			<div class="voiceToTextContext" id="scrollVoice">
1236
-				<div class="clientChat">
1236
+				<!--<div class="clientChat">
1237 1237
 					<img src="img/youkeTx.png">
1238 1238
 					<div class="clientChatText">你好</div>
1239 1239
 				</div>
1240 1240
 				<div class="serviceChat">
1241 1241
 					<img src="img/kefuTx.png">
1242
-					<div class="serviceChatText">你好,有什么要咨询的吗</div>
1242
+					<div class="serviceChatText">你好,有什么要咨询的吗你好</div>
1243 1243
 				</div>
1244 1244
 				<div class="clientChat">
1245 1245
 					<img src="img/youkeTx.png">
1246
-					<div class="clientChatText">你好</div>
1247
-				</div>
1248
-				<div class="serviceChat">
1249
-					<img src="img/kefuTx.png">
1250
-					<div class="serviceChatText">你好,有什么要咨询的吗</div>
1251
-				</div>
1252
-				<div class="clientChat">
1253
-					<img src="img/youkeTx.png">
1254
-					<div class="clientChatText">你好</div>
1246
+					<div class="clientChatText">你好,有什么要咨询的吗你好,有什么要咨询的吗你好,有什么要咨询的吗你好,有什么要咨询的吗你好,有什么要咨询的吗</div>
1255 1247
 				</div>
1256 1248
 				<div class="serviceChat">
1257 1249
 					<img src="img/kefuTx.png">
1258
-					<div class="serviceChatText">你好,有什么要咨询的吗</div>
1259
-				</div>
1260
-				<div class="clientChat">
1261
-					<img src="img/youkeTx.png">
1262
-					<div class="clientChatText">你好</div>
1263
-				</div>
1264
-				<div class="serviceChat">
1265
-					<img src="img/kefuTx.png">
1266
-					<div class="serviceChatText">你好,有什么要咨询的吗</div>
1267
-				</div>
1250
+					<div class="serviceChatText">你好,有什么要咨询的吗你好,有什么要咨询的吗你好,有什么要咨询的吗你好,有什么要咨询的吗你好,有什么要咨询的吗</div>
1251
+				</div>-->
1268 1252
 			</div>
1269 1253
 		</div>
1270 1254
 		<script src="https://api.map.baidu.com/api?v=2.0&ak=ZG4gLQZUD6Eq1K11cqlYAR4by8CKgLyu&callback=mapinit"></script>
@@ -1289,7 +1273,7 @@
1289 1273
 		<script src="./js/ztreeSelect.js"></script>
1290 1274
 		<script src="js/voiceToText.js"></script>
1291 1275
 		
1292
-		<!--<script  src="./js/voiceToTextSocket/socket.js"></script>-->
1276
+		<script  src="./js/voiceToTextSocket/socket.js"></script>
1293 1277
 		<script>
1294 1278
 			var logpas = localStorage.getItem('loginPassword')
1295 1279
 			var userphone = $.cookie('userMobile')

+ 20 - 18
WebUI/CallCenterWeb.UI/js/index.js

@@ -58,24 +58,15 @@ $(document).ready(function() {
58 58
 		$(".maxOpen").show();
59 59
 		$(".maxOpen").addClass("fadeInDown");
60 60
 	});
61
-	layer.open({
62
-		type: 2,
63
-		content: "./callout/videoCall.html", //iframe的url,no代表不显示滚动条
64
-		title: "视频通话窗口",
65
-		shade: 0,
66
-		offset: "rb",
67
-		area: ["22%", "65%"], //宽高
68
-	});
69
-//	if($.cookie("code") == "spdbzy") {
70
-//		layer.open({
71
-//			type: 2,
72
-//			content: "./callout/videoCall.html", //iframe的url,no代表不显示滚动条
73
-//			title: "视频通话窗口",
74
-//			shade: 0,
75
-//			offset: "rb",
76
-//			area: ["22%", "65%"], //宽高
77
-//		});
78
-//	}
61
+//	layer.open({
62
+//		type: 2,
63
+//		content: "./callout/videoCall.html", //iframe的url,no代表不显示滚动条
64
+//		title: "视频通话窗口",
65
+//		shade: 0,
66
+//		offset: "rb",
67
+//		area: ["22%", "65%"], //宽高
68
+//	});
69
+	
79 70
 
80 71
 	//最大化
81 72
 	$(".maxOpen").click(function() {
@@ -274,6 +265,17 @@ $(document).ready(function() {
274 265
 				$(".settingTelephone").val(result.data.user.F_Telephone);
275 266
 				if(result.data.user.F_SeatFlag) {
276 267
 					Connect();
268
+					connectVoice(1); //创建连接 
269
+//					if($.cookie("code") == "spdbzy") {
270
+//						layer.open({
271
+//							type: 2,
272
+//							content: "./callout/videoCall.html", //iframe的url,no代表不显示滚动条
273
+//							title: "视频通话窗口",
274
+//							shade: 0,
275
+//							offset: "rb",
276
+//							area: ["22%", "65%"], //宽高
277
+//						});
278
+//					}
277 279
 					//CreateWebSockets();
278 280
 					//$(".open_chat").show();
279 281
 					//heartbeat = setInterval(function() {

+ 7 - 5
WebUI/CallCenterWeb.UI/js/main.js

@@ -26,11 +26,12 @@ function createWebSocket() {
26 26
 }
27 27
 //连接
28 28
 function Connect() {
29
-	if($.cookie("code")!="spdbzy"){
30
-		ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
31
-	} else {
32
-		ws = new WebSocket("wss://" + huayi.config.videoSocket_ip + ":" + huayi.config.videoSocket_port);
33
-	}
29
+	ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
30
+//	if($.cookie("code")!="spdbzy"){
31
+//		ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
32
+//	} else {
33
+//		ws = new WebSocket("wss://" + huayi.config.videoSocket_ip + ":" + huayi.config.videoSocket_port);
34
+//	}
34 35
     console.log(ws)
35 36
     ws.onopen = function () {
36 37
         console.log(new Date() + "    " + "建立连接");
@@ -262,6 +263,7 @@ function LogoutBack() {
262 263
 
263 264
 //来电
264 265
 function IncomingBack(data) {
266
+	$(".voiceToTextContext").html('')
265 267
     $(".ldhm").val(data.Number);
266 268
     $(".hidTel").val(data.Number);
267 269
     $(".tel").text(data.Number);

+ 7 - 4
WebUI/CallCenterWeb.UI/js/voiceToText.css

@@ -52,17 +52,19 @@
52 52
 	overflow: hidden;
53 53
 }
54 54
 .clientChat img{
55
-	width: 40px;
55
+	width:12%;
56 56
 	border-radius: 20px;
57 57
 	float: left;
58 58
 }
59 59
 .clientChat .clientChatText{
60 60
 	float: left;
61
+	max-width: 80%;
61 62
 	display: inline-block;
62
-	margin-left: 15px;
63
+	margin-left: 2%;
63 64
 	background: #bde0ff;
64 65
 	border-radius: 0px 5px 5px 5px ;
65 66
 	padding: 8px;
67
+	
66 68
 }
67 69
 .serviceChat{
68 70
 	width: 100%;
@@ -70,13 +72,14 @@
70 72
 	overflow: hidden;
71 73
 }
72 74
 .serviceChat img{
73
-	width: 40px;
75
+	width: 12%;
74 76
 	border-radius: 20px;
75 77
 	float: right;
76 78
 }
77 79
 .serviceChat .serviceChatText{
78 80
 	float: right;
79
-	margin-right: 15px;
81
+	max-width: 80%;
82
+	margin-right: 2%;
80 83
 	display: inline-block;
81 84
 	border: 1px solid #CCCCCC;
82 85
 	border-radius: 5px 0px 5px 5px ;

+ 126 - 125
WebUI/CallCenterWeb.UI/js/voiceToText.js

@@ -1,31 +1,4 @@
1 1
 
2
-var clientChatHtml = ''
3
-var serviceChatHtml = ''
4
-var objVoice ={
5
-	agent_id:'8000',
6
-	timestamp:new Date().getTime(),
7
-	data:''
8
-}
9
-//VoiceCommAPI.setConfigureServer("http://配置服务器 URL");
10
-//var agent = VoiceCommAPI.createAgentControl();
11
-//agent.login(objVoice);
12
-//agent.setDetectSpeechEventListener(objVoice,function(data){})
13
-//agent.on('setDetectSpeechEventListener',function(data){})
14
-
15
-setTimeout(function(){
16
-	
17
-	for(var i = 0; i < voiceToTextContextAway.length; i++) {
18
-		if (voiceToTextContextAway[i].type=="clientChat") {
19
-			$('<div class="clientChat"><img src="img/youkeTx.png"><div class="clientChatText">'+
20
-			voiceToTextContextAway[i].clientChat+'</div></div>').appendTo($(".voiceToTextContext"));
21
-		} else if(voiceToTextContextAway[i].type=="serviceChat"){
22
-			$('<div class="serviceChat"><img src="img/kefuTx.png"><div class="serviceChatText">'+
23
-			voiceToTextContextAway[i].serviceChat+'</div></div>').appendTo($(".voiceToTextContext"));
24
-		}
25
-	}
26
-	
27
-	scrollTopFn("scrollVoice")
28
-},2000)
29 2
 $("#clickElementVoice").click(function(){
30 3
 	var elThis = $(this)
31 4
 	voiceTextToggle(elThis,1000)
@@ -62,101 +35,129 @@ function showFn(el,timeToggle){
62 35
 		timeoutShow= null
63 36
 	},timeToggle)
64 37
 }
65
-var voiceToTextContextAway = [
66
-	{
67
-		type:"clientChat",
68
-		clientChat:'你知道2020年我最宝贵的是什么吗'
69
-	},
70
-	{
71
-		type:"serviceChat",
72
-		serviceChat:'什么哟'
73
-	},
74
-	{
75
-		type:"clientChat",
76
-		clientChat:'我刚说的那句话的第一个字'
77
-	},
78
-	{
79
-		type:"clientChat",
80
-		clientChat:'啊 我的心好痛'
81
-	},
82
-	{
83
-		type:"serviceChat",
84
-		serviceChat:'怎么了'
85
-	},
86
-	{
87
-		type:"clientChat",
88
-		clientChat:'你卡在我心上了'
89
-	},
90
-	{
91
-		type:"clientChat",
92
-		clientChat:'我第一次见到你我就发烧了'
93
-	},
94
-	{
95
-		type:"serviceChat",
96
-		serviceChat:'为什么'
97
-	},
98
-	{
99
-		type:"clientChat",
100
-		clientChat:'因为一见钟情的体温是38°6啊'
101
-	},
102
-	{
103
-		type:"clientChat",
104
-		clientChat:'你知道我现在最想喝什么吗?'
105
-	},
106
-	{
107
-		type:"serviceChat",
108
-		serviceChat:'喝什么?'
109
-	},
110
-	{
111
-		type:"clientChat",
112
-		clientChat:'呵护你。'
113
-	},
114
-	{
115
-		type:"clientChat",
116
-		clientChat:'我觉得我好像见过你'
117
-	},
118
-	{
119
-		type:"serviceChat",
120
-		serviceChat:'在哪?'
121
-	},
122
-	{
123
-		type:"clientChat",
124
-		clientChat:'在我的结婚证上'
125
-	},
126
-	{
127
-		type:"clientChat",
128
-		clientChat:'你喜欢吃糖吗'
129
-	},
130
-	{
131
-		type:"serviceChat",
132
-		serviceChat:'不喜欢'
133
-	},
134
-	{
135
-		type:"clientChat",
136
-		clientChat:'那为什么你还这么甜'
137
-	},
138
-	{
139
-		type:"clientChat",
140
-		clientChat:'你跑的快吗?'
141
-	},
142
-	{
143
-		type:"serviceChat",
144
-		serviceChat:'不太快。'
145
-	},
146
-	{
147
-		type:"clientChat",
148
-		clientChat:'那太好了,我一定能追到你。'
149
-	},
150
-	{
151
-		type:"clientChat",
152
-		clientChat:'有一个很美的故事'
153
-	},
154
-	{
155
-		type:"serviceChat",
156
-		serviceChat:'什么故事'
157
-	},
158
-	{
159
-		type:"clientChat",
160
-		clientChat:'就是你遇见我的事'
161
-	},
162
-]
38
+
39
+//var clientChatHtml = ''
40
+//var serviceChatHtml = ''
41
+//var objVoice ={
42
+//	agent_id:'8000',
43
+//	timestamp:new Date().getTime(),
44
+//	data:''
45
+//}
46
+//VoiceCommAPI.setConfigureServer("ws://222.143.106.46:12233");
47
+//var agent = VoiceCommAPI.createAgentControl();
48
+//agent.login(objVoice);
49
+//agent.setDetectSpeechEventListener(objVoice,function(data){})
50
+//agent.on('setDetectSpeechEventListener',function(data){})
51
+
52
+//setTimeout(function(){
53
+//	
54
+//	for(var i = 0; i < voiceToTextContextAway.length; i++) {
55
+//		if (voiceToTextContextAway[i].type=="clientChat") {
56
+//			$('<div class="clientChat"><img src="img/youkeTx.png"><div class="clientChatText">'+
57
+//			voiceToTextContextAway[i].clientChat+'</div></div>').appendTo($(".voiceToTextContext"));
58
+//		} else if(voiceToTextContextAway[i].type=="serviceChat"){
59
+//			$('<div class="serviceChat"><img src="img/kefuTx.png"><div class="serviceChatText">'+
60
+//			voiceToTextContextAway[i].serviceChat+'</div></div>').appendTo($(".voiceToTextContext"));
61
+//		}
62
+//	}
63
+//	
64
+//	
65
+//},2000)
66
+//var voiceToTextContextAway = [
67
+//	{
68
+//		type:"clientChat",
69
+//		clientChat:'你知道2020年我最宝贵的是什么吗'
70
+//	},
71
+//	{
72
+//		type:"serviceChat",
73
+//		serviceChat:'什么哟'
74
+//	},
75
+//	{
76
+//		type:"clientChat",
77
+//		clientChat:'我刚说的那句话的第一个字'
78
+//	},
79
+//	{
80
+//		type:"clientChat",
81
+//		clientChat:'啊 我的心好痛'
82
+//	},
83
+//	{
84
+//		type:"serviceChat",
85
+//		serviceChat:'怎么了'
86
+//	},
87
+//	{
88
+//		type:"clientChat",
89
+//		clientChat:'你卡在我心上了'
90
+//	},
91
+//	{
92
+//		type:"clientChat",
93
+//		clientChat:'我第一次见到你我就发烧了'
94
+//	},
95
+//	{
96
+//		type:"serviceChat",
97
+//		serviceChat:'为什么'
98
+//	},
99
+//	{
100
+//		type:"clientChat",
101
+//		clientChat:'因为一见钟情的体温是38°6啊'
102
+//	},
103
+//	{
104
+//		type:"clientChat",
105
+//		clientChat:'你知道我现在最想喝什么吗?'
106
+//	},
107
+//	{
108
+//		type:"serviceChat",
109
+//		serviceChat:'喝什么?'
110
+//	},
111
+//	{
112
+//		type:"clientChat",
113
+//		clientChat:'呵护你。'
114
+//	},
115
+//	{
116
+//		type:"clientChat",
117
+//		clientChat:'我觉得我好像见过你'
118
+//	},
119
+//	{
120
+//		type:"serviceChat",
121
+//		serviceChat:'在哪?'
122
+//	},
123
+//	{
124
+//		type:"clientChat",
125
+//		clientChat:'在我的结婚证上'
126
+//	},
127
+//	{
128
+//		type:"clientChat",
129
+//		clientChat:'你喜欢吃糖吗'
130
+//	},
131
+//	{
132
+//		type:"serviceChat",
133
+//		serviceChat:'不喜欢'
134
+//	},
135
+//	{
136
+//		type:"clientChat",
137
+//		clientChat:'那为什么你还这么甜'
138
+//	},
139
+//	{
140
+//		type:"clientChat",
141
+//		clientChat:'你跑的快吗?'
142
+//	},
143
+//	{
144
+//		type:"serviceChat",
145
+//		serviceChat:'不太快。'
146
+//	},
147
+//	{
148
+//		type:"clientChat",
149
+//		clientChat:'那太好了,我一定能追到你。'
150
+//	},
151
+//	{
152
+//		type:"clientChat",
153
+//		clientChat:'有一个很美的故事'
154
+//	},
155
+//	{
156
+//		type:"serviceChat",
157
+//		serviceChat:'什么故事'
158
+//	},
159
+//	{
160
+//		type:"clientChat",
161
+//		clientChat:'就是你遇见我的事'
162
+//	},
163
+//]

+ 32 - 8
WebUI/CallCenterWeb.UI/js/voiceToTextSocket/socket.js

@@ -1,18 +1,21 @@
1 1
 var socketVoice = []; //websocket对象数组
2 2
 var getTimeStringVoice = new Date().getTime().toString();
3 3
 var objNew ={}
4
-//connectVoice(); //创建连接 
4
+
5 5
 //创建socket连接功能函数  
6 6
 function connectVoice(wsobj) {
7 7
 	//浏览器支持?
8 8
 	if("WebSocket" in window) {
9
-		var host = "ws://218.29.229.185:8081/"
9
+		var extno = $.cookie("extno")
10
+//		var extno = "1001"
11
+		var host = huayi.config.translation_socket+"/"+extno
12
+		console.log(host)
10 13
 		socketVoice = new WebSocket(host);
11 14
 		try {
12 15
 			//连接事件
13 16
 			socketVoice.onopen = function(msg) {
14 17
 				console.log(wsobj + ":连接已建立!")
15
-				videoReqExten()
18
+//				videoReqExten()
16 19
 			};
17 20
 			//错误事件	
18 21
 			socketVoice.onerror = function(msg) {
@@ -20,10 +23,20 @@ function connectVoice(wsobj) {
20 23
 			}
21 24
 			//消息事件
22 25
 			socketVoice.onmessage = function(msg) {
23
-				console.log(wsobj+"消息接收:"+msg.data)
26
+       			 //最后转回json对象
27
+      			data = eval('(' + msg.data + ')');
28
+      			console.log(msg.data)
29
+      			console.log(data.event,data.data.label,data.data.content);
30
+      			switch (data.event.toLowerCase()) {
31
+					case "translation":
32
+                        translationBack(data);
33
+                        break; //签入
34
+                }
35
+//				console.log(wsobj+"消息接收:"+data.data)
24 36
 			};
25 37
 			//关闭事件
26 38
 			socketVoice.onclose = function(msg) {
39
+				connectVoice(1)
27 40
 				console.log(wsobj + ":socket closed!")
28 41
 			};
29 42
 		} catch(ex) {
@@ -37,10 +50,10 @@ function connectVoice(wsobj) {
37 50
 }
38 51
 //申请注册的分机
39 52
  function videoReqExten() {
40
- 	objNew.Type = "VideoReqExten";
41
- 	objNew.AgentID = getTimeStringVoice.substring(getTimeStringVoice.length-9);
42
-	objNew.AgentExten = "111";
43
- 	SendVoice()
53
+// 	objNew.Type = "VideoReqExten";
54
+// 	objNew.AgentID = getTimeStringVoice.substring(getTimeStringVoice.length-9);
55
+//	objNew.AgentExten = "111";
56
+   	SendVoice()
44 57
  }
45 58
  //发送
46 59
 function SendVoice() {
@@ -53,3 +66,14 @@ function SendVoice() {
53 66
         objNew.Type = "";
54 67
     }
55 68
 }
69
+
70
+function translationBack(data) {
71
+	if(data.data.label === "坐席"){
72
+		$('<div class="serviceChat"><img src="img/kefuTx.png"><div class="serviceChatText">'+
73
+			data.data.content+'</div></div>').appendTo($(".voiceToTextContext"))
74
+	} else if (data.data.label === "客户") {
75
+		$('<div class="clientChat"><img src="img/youkeTx.png"><div class="clientChatText">'+
76
+			data.data.content+'</div></div>').appendTo($(".voiceToTextContext"));
77
+	}
78
+	scrollTopFn("scrollVoice")
79
+}