fix bug for h5 hotwords (#1067)

* fix bug for h5 hotwords

* make changes for main.js

* change json from string to object

* change from object to string for hotwords
This commit is contained in:
zhaomingwork 2023-11-08 09:22:06 +08:00 committed by GitHub
parent 301d0522bb
commit 2e36e738ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -262,7 +262,7 @@ function getHotwords(){
var obj = document.getElementById("varHot"); var obj = document.getElementById("varHot");
if(typeof(obj) == 'undefined' || obj==null || obj.value.length<=0){ if(typeof(obj) == 'undefined' || obj==null || obj.value.length<=0){
return ""; return null;
} }
let val = obj.value.toString(); let val = obj.value.toString();
@ -279,11 +279,11 @@ function getHotwords(){
for(var i=0;i<result.length-1;i++) for(var i=0;i<result.length-1;i++)
wordstr=wordstr+result[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)); console.log("jsonresult="+JSON.stringify(jsonresult));
return jsonresult; return JSON.stringify(jsonresult);
} }
function getAsrMode(){ function getAsrMode(){

View File

@ -85,12 +85,13 @@ function WebSocketConnectMethod( config ) { //定义socket连接方法类
} }
var hotwords=getHotwords(); var hotwords=getHotwords();
if(hotwords.length>0)
if(hotwords!=null )
{ {
request.hotwords=hotwords; request.hotwords=hotwords;
} }
console.log(request); console.log(JSON.stringify(request));
speechSokt.send( JSON.stringify(request) ); speechSokt.send(JSON.stringify(request));
console.log("连接成功"); console.log("连接成功");
stateHandle(0); stateHandle(0);