From 28ccfbfc51068a663a80764e14074df5edf2b5ba Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期五, 13 三月 2026 17:41:41 +0800
Subject: [PATCH] 提交

---
 runtime/html5/static/main.js |   40 +++++++++++++++++++++++++++++-----------
 1 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/runtime/html5/static/main.js b/runtime/html5/static/main.js
index 52a8d96..9655a50 100644
--- a/runtime/html5/static/main.js
+++ b/runtime/html5/static/main.js
@@ -262,7 +262,7 @@
 	var obj = document.getElementById("varHot");
 
 	if(typeof(obj) == 'undefined' || obj==null || obj.value.length<=0){
-	  return "";
+	  return null;
 	}
 	let val = obj.value.toString();
   
@@ -279,11 +279,11 @@
 			for(var i=0;i<result.length-1;i++)
 				wordstr=wordstr+result[i]+" ";
   
-			jsonresult[wordstr.trim()]=result[result.length-1];
+			jsonresult[wordstr.trim()]= parseInt(result[result.length-1]);
 		}
 	}
 	console.log("jsonresult="+JSON.stringify(jsonresult));
-	return jsonresult;
+	return  JSON.stringify(jsonresult);
 
 }
 function getAsrMode(){
@@ -315,10 +315,10 @@
 	{
 		return tmptext;
 	}
-	tmptext=tmptext.replace(/銆�/g, ","); // in case there are a lot of "銆�"
-	var words=tmptext.split(",");
+	tmptext=tmptext.replace(/銆倈锛焲锛寍銆亅\?|\.|\ /g, ","); // in case there are a lot of "銆�"
+	var words=tmptext.split(",");  // split to chinese sentence or english words
 	var jsontime=JSON.parse(tmptime); //JSON.parse(tmptime.replace(/\]\]\[\[/g, "],[")); // in case there are a lot segments by VAD
-	var char_index=0;
+	var char_index=0; // index for timestamp
 	var text_withtime="";
 	for(var i=0;i<words.length;i++)
 	{   
@@ -326,10 +326,18 @@
 	{
 		continue;
 	}
-        console.log("words===",words[i]);
-		console.log( "words: " + words[i]+",time="+jsontime[char_index][0]/1000);
+    console.log("words===",words[i]);
+	console.log( "words: " + words[i]+",time="+jsontime[char_index][0]/1000);
+	if (/^[a-zA-Z]+$/.test(words[i]))
+	{   // if it is english
 		text_withtime=text_withtime+jsontime[char_index][0]/1000+":"+words[i]+"\n";
-		char_index=char_index+words[i].length;
+		char_index=char_index+1;  //for english, timestamp unit is about a word
+	}
+	else{
+        // if it is chinese
+		text_withtime=text_withtime+jsontime[char_index][0]/1000+":"+words[i]+"\n";
+		char_index=char_index+words[i].length; //for chinese, timestamp unit is about a char
+	}
 	}
 	return text_withtime;
 	
@@ -358,7 +366,7 @@
 	varArea.value=rec_text;
 	console.log( "offline_text: " + asrmodel+","+offline_text);
 	console.log( "rec_text: " + rec_text);
-	if (isfilemode==true && is_final==false){
+	if (isfilemode==true && is_final==true){
 		console.log("call stop ws!");
 		play_file();
 		wsconnecter.wsStop();
@@ -555,4 +563,14 @@
  
 		
 	}
-}
\ No newline at end of file
+}
+
+function getUseITN() {
+	var obj = document.getElementsByName("use_itn");
+	for (var i = 0; i < obj.length; i++) {
+		if (obj[i].checked) {
+			return obj[i].value === "true";
+		}
+	}
+	return false;
+}

--
Gitblit v1.9.1