From bc723ea200144bd6fa8a5dff4b9a780feda144fc Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期四, 29 六月 2023 18:55:01 +0800
Subject: [PATCH] dcos
---
funasr/runtime/html5/static/wsconnecter.js | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/funasr/runtime/html5/static/wsconnecter.js b/funasr/runtime/html5/static/wsconnecter.js
index 82d751b..2873022 100644
--- a/funasr/runtime/html5/static/wsconnecter.js
+++ b/funasr/runtime/html5/static/wsconnecter.js
@@ -15,8 +15,7 @@
this.wsStart = function () {
var Uri = document.getElementById('wssip').value; //"wss://111.205.137.58:5821/wss/" //璁剧疆wss asr online鎺ュ彛鍦板潃 濡� wss://X.X.X.X:port/wss/
-
- if(Uri.match(/wss:\S*/))
+ if(Uri.match(/wss:\S*|ws:\S*/))
{
console.log("Uri"+Uri);
}
@@ -25,10 +24,15 @@
alert("璇锋鏌ss鍦板潃姝g‘鎬�");
return 0;
}
+
if ( 'WebSocket' in window ) {
speechSokt = new WebSocket( Uri ); // 瀹氫箟socket杩炴帴瀵硅薄
speechSokt.onopen = function(e){onOpen(e);}; // 瀹氫箟鍝嶅簲鍑芥暟
- speechSokt.onclose = function(e){onClose(e);};
+ speechSokt.onclose = function(e){
+ console.log("onclose ws!");
+ //speechSokt.close();
+ onClose(e);
+ };
speechSokt.onmessage = function(e){onMessage(e);};
speechSokt.onerror = function(e){onError(e);};
return 1;
@@ -42,20 +46,18 @@
// 瀹氫箟鍋滄涓庡彂閫佸嚱鏁�
this.wsStop = function () {
if(speechSokt != undefined) {
+ console.log("stop ws!");
speechSokt.close();
}
};
- this.wsSend = function ( oneData,stop ) {
+ this.wsSend = function ( oneData ) {
if(speechSokt == undefined) return;
if ( speechSokt.readyState === 1 ) { // 0:CONNECTING, 1:OPEN, 2:CLOSING, 3:CLOSED
speechSokt.send( oneData );
- if(stop){
- setTimeout(speechSokt.close(), 3000 );
- }
}
};
@@ -69,10 +71,13 @@
"wav_name": "h5",
"is_speaking": true,
"chunk_interval":10,
+ "mode":getAsrMode(),
};
+ console.log(request);
speechSokt.send( JSON.stringify(request) );
console.log("杩炴帴鎴愬姛");
stateHandle(0);
+
}
function onClose( e ) {
@@ -85,9 +90,11 @@
}
function onError( e ) {
+
info_div.innerHTML="杩炴帴"+e;
console.log(e);
stateHandle(2);
+
}
--
Gitblit v1.9.1