From 8ceb2662f95d6e9185a00b7ccbff3ee596d46342 Mon Sep 17 00:00:00 2001
From: zhaomingwork <61895407+zhaomingwork@users.noreply.github.com>
Date: 星期二, 14 十一月 2023 19:28:31 +0800
Subject: [PATCH] set itn to false for timestamp problem (#1088)
---
runtime/html5/static/main.js | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/runtime/html5/static/main.js b/runtime/html5/static/main.js
index 20aa220..b3661cd 100644
--- a/runtime/html5/static/main.js
+++ b/runtime/html5/static/main.js
@@ -315,10 +315,10 @@
{
return tmptext;
}
- tmptext=tmptext.replace(/銆倈锛焲锛寍銆亅\?|\./g, ","); // replace all punc for parse
- 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;
--
Gitblit v1.9.1