Skip to content

Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.

fix bug for h5 hotwords (#1067)

zhaomingwork2e36e738ca39
diff --git a/runtime/html5/static/main.js b/runtime/html5/static/main.js
index 52a8d96d8..e8408e9a5 100644
--- a/runtime/html5/static/main.js
+++ b/runtime/html5/static/main.js
@@ -262,7 +262,7 @@ function getHotwords(){
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 @@ function getHotwords(){
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(){
diff --git a/runtime/html5/static/wsconnecter.js b/runtime/html5/static/wsconnecter.js
index b9a786de5..455e1a125 100644
--- a/runtime/html5/static/wsconnecter.js
+++ b/runtime/html5/static/wsconnecter.js
@@ -85,12 +85,13 @@ function WebSocketConnectMethod( config ) { //定义socket连接方法类
}
var hotwords=getHotwords();
- if(hotwords.length>0)
+
+ if(hotwords!=null )
{
request.hotwords=hotwords;
}
- console.log(request);
- speechSokt.send( JSON.stringify(request) );
+ console.log(JSON.stringify(request));
+ speechSokt.send(JSON.stringify(request));
console.log("连接成功");
stateHandle(0);