From 6bdae5723e403584ee3507675b3e4e922a34f246 Mon Sep 17 00:00:00 2001
From: lingyunfly <121302812+lingyunfly@users.noreply.github.com>
Date: 星期五, 09 六月 2023 16:19:35 +0800
Subject: [PATCH] Optimize memory (#612)
---
funasr/runtime/html5/static/wsconnecter.js | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/funasr/runtime/html5/static/wsconnecter.js b/funasr/runtime/html5/static/wsconnecter.js
index 4b22e8f..676a94a 100644
--- a/funasr/runtime/html5/static/wsconnecter.js
+++ b/funasr/runtime/html5/static/wsconnecter.js
@@ -5,7 +5,8 @@
/* 2021-2023 by zhaoming,mali aihealthx.com */
function WebSocketConnectMethod( config ) { //瀹氫箟socket杩炴帴鏂规硶绫�
- var Uri = "wss://111.205.137.58:5821/wss/" //璁剧疆wss asr online鎺ュ彛鍦板潃 濡� wss://X.X.X.X:port/wss/
+
+
var speechSokt;
var connKeeperID;
@@ -13,22 +14,39 @@
var stateHandle = config.stateHandle;
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*/))
+ {
+ console.log("Uri"+Uri);
+ }
+ else
+ {
+ 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;
}
else {
alert('褰撳墠娴忚鍣ㄤ笉鏀寔 WebSocket');
+ return 0;
}
};
// 瀹氫箟鍋滄涓庡彂閫佸嚱鏁�
this.wsStop = function () {
if(speechSokt != undefined) {
+ console.log("stop ws!");
speechSokt.close();
}
};
@@ -56,7 +74,9 @@
"wav_name": "h5",
"is_speaking": true,
"chunk_interval":10,
+ "mode":getAsrMode(),
};
+ console.log(request);
speechSokt.send( JSON.stringify(request) );
console.log("杩炴帴鎴愬姛");
stateHandle(0);
--
Gitblit v1.9.1