From 4870f0f8a5f3ae9072a56b6f320ba7ebcfaf4373 Mon Sep 17 00:00:00 2001
From: Binbin Gu <gubinbin@outlook.com>
Date: 星期五, 02 六月 2023 11:51:02 +0800
Subject: [PATCH] Update cardinal.py (#562)

---
 funasr/runtime/html5/static/main.js |   44 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/funasr/runtime/html5/static/main.js b/funasr/runtime/html5/static/main.js
index eaa257a..be57df1 100644
--- a/funasr/runtime/html5/static/main.js
+++ b/funasr/runtime/html5/static/main.js
@@ -30,20 +30,49 @@
  
 
  
-var rec_text=""
+var rec_text="";
+var offline_text="";
 var info_div = document.getElementById('info_div');
 
-var now_ipaddress=window.location.href;
-now_ipaddress=now_ipaddress.replace("https://","wss://");   
-now_ipaddress=now_ipaddress.replace("static/index.html","");   
-document.getElementById('wssip').value=now_ipaddress;
+//var now_ipaddress=window.location.href;
+//now_ipaddress=now_ipaddress.replace("https://","wss://");
+//now_ipaddress=now_ipaddress.replace("static/index.html","");
+//document.getElementById('wssip').value=now_ipaddress;
+
+function getAsrMode(){
+
+            var item = null;
+            var obj = document.getElementsByName("asr_mode");
+            for (var i = 0; i < obj.length; i++) { //閬嶅巻Radio 
+                if (obj[i].checked) {
+                    item = obj[i].value;  
+					break;
+                }
+		    
+
+           }
+		   console.log("asr mode"+item);
+		   return item;
+}
+		   
 
 // 璇煶璇嗗埆缁撴灉; 瀵筳sonMsg鏁版嵁瑙f瀽,灏嗚瘑鍒粨鏋滈檮鍔犲埌缂栬緫妗嗕腑
 function getJsonMessage( jsonMsg ) {
+	//console.log(jsonMsg);
 	console.log( "message: " + JSON.parse(jsonMsg.data)['text'] );
 	var rectxt=""+JSON.parse(jsonMsg.data)['text'];
+	var asrmodel=JSON.parse(jsonMsg.data)['mode'];
+	if(asrmodel=="2pass-offline")
+	{
+		offline_text=offline_text+rectxt.replace(/ +/g,"");
+		rec_text=offline_text;
+	}
+	else
+	{
+		rec_text=rec_text+rectxt.replace(/ +/g,"");
+	}
 	var varArea=document.getElementById('varArea');
-	rec_text=rec_text+rectxt.replace(/ +/g,"");
+	
 	varArea.value=rec_text;
 	 
  
@@ -97,7 +126,9 @@
 			"wav_name":  "h5",
 			"is_speaking":  false,
 			"chunk_interval":10,
+			"mode":getAsrMode(),
 		};
+		console.log(request);
 		if(sampleBuf.length>0){
 		wsconnecter.wsSend(sampleBuf,false);
 		console.log("sampleBuf.length"+sampleBuf.length);
@@ -149,6 +180,7 @@
  
 	varArea.value="";
     rec_text="";
+	offline_text="";
  
 }
 

--
Gitblit v1.9.1