mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
set itn to false for timestamp problem (#1088)
This commit is contained in:
parent
f2ac5efe7a
commit
8ceb2662f9
@ -315,10 +315,10 @@ function handleWithTimestamp(tmptext,tmptime)
|
||||
{
|
||||
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 @@ function handleWithTimestamp(tmptext,tmptime)
|
||||
{
|
||||
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;
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ function WebSocketConnectMethod( config ) { //定义socket连接方法类
|
||||
"wav_name": "h5",
|
||||
"is_speaking": true,
|
||||
"chunk_interval":10,
|
||||
"itn":false,
|
||||
"mode":getAsrMode(),
|
||||
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user