From d7e3ae17c3ac056752ecf5c41ff9a96645fcad49 Mon Sep 17 00:00:00 2001
From: zhaomingwork <61895407+zhaomingwork@users.noreply.github.com>
Date: 星期一, 12 六月 2023 21:41:04 +0800
Subject: [PATCH] add connect button for ws html5 (#621)
---
funasr/runtime/html5/static/index.html | 1 +
funasr/runtime/html5/static/main.js | 41 +++++++++++++++++++++++++++++------------
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/funasr/runtime/html5/static/index.html b/funasr/runtime/html5/static/index.html
index 3cd8dad..99aa9b4 100644
--- a/funasr/runtime/html5/static/index.html
+++ b/funasr/runtime/html5/static/index.html
@@ -36,6 +36,7 @@
<br>
<div id="info_div">璇风偣鍑诲紑濮�</div>
<div class="div_class_buttons">
+ <button id="btnConnect">杩炴帴</button>
<button id="btnStart">寮�濮�</button>
<button id="btnStop">鍋滄</button>
diff --git a/funasr/runtime/html5/static/main.js b/funasr/runtime/html5/static/main.js
index 9317778..412bb43 100644
--- a/funasr/runtime/html5/static/main.js
+++ b/funasr/runtime/html5/static/main.js
@@ -23,12 +23,14 @@
var sampleBuf=new Int16Array();
// 瀹氫箟鎸夐挳鍝嶅簲浜嬩欢
var btnStart = document.getElementById('btnStart');
-btnStart.onclick = start;
+btnStart.onclick = record;
var btnStop = document.getElementById('btnStop');
btnStop.onclick = stop;
btnStop.disabled = true;
+btnStart.disabled = true;
-
+btnConnect= document.getElementById('btnConnect');
+btnConnect.onclick = start;
var rec_text="";
var offline_text="";
@@ -38,7 +40,7 @@
//now_ipaddress=now_ipaddress.replace("https://","wss://");
//now_ipaddress=now_ipaddress.replace("static/index.html","");
//document.getElementById('wssip').value=now_ipaddress;
-
+
function getAsrMode(){
var item = null;
@@ -82,11 +84,14 @@
function getConnState( connState ) {
if ( connState === 0 ) {
- rec.open( function(){
- rec.start();
- console.log("寮�濮嬪綍闊�");
+ //rec.open( function(){
+ // rec.start();
+ // console.log("寮�濮嬪綍闊�");
- });
+ //});
+ btnStart.disabled = false;
+ btnConnect.disabled = true;
+ info_div.innerHTML='杩炴帴鎴愬姛!璇风偣鍑诲紑濮�';
} else if ( connState === 1 ) {
//stop();
} else if ( connState === 2 ) {
@@ -95,11 +100,19 @@
alert("杩炴帴鍦板潃"+document.getElementById('wssip').value+"澶辫触,璇锋鏌sr鍦板潃鍜岀鍙o紝骞剁‘淇漢5鏈嶅姟鍜宎sr鏈嶅姟鍦ㄥ悓涓�涓煙鍐呫�傛垨鎹釜娴忚鍣ㄨ瘯璇曘��");
btnStart.disabled = true;
- info_div.innerHTML='璇风偣鍑诲紑濮�';
+
+ info_div.innerHTML='璇风偣鍑昏繛鎺�';
}
}
-
+function record()
+{
+ rec.open( function(){
+ rec.start();
+ console.log("寮�濮�");
+ btnStart.disabled = true;
+ });
+}
// 璇嗗埆鍚姩銆佸仠姝€�佹竻绌烘搷浣�
function start() {
@@ -107,14 +120,15 @@
clear();
//鎺т欢鐘舵�佹洿鏂�
-
+ info_div.innerHTML="姝e湪杩炴帴asr鏈嶅姟鍣紝璇风瓑寰�...";
//鍚姩杩炴帴
var ret=wsconnecter.wsStart();
if(ret==1){
isRec = true;
btnStart.disabled = true;
btnStop.disabled = false;
- info_div.innerHTML="姝e湪杩炴帴asr鏈嶅姟鍣紝璇风瓑寰�...";
+ btnConnect.disabled=true;
+
}
}
@@ -147,7 +161,10 @@
btnStop.disabled = true;
setTimeout(function(){
console.log("call stop ws!");
- wsconnecter.wsStop();btnStart.disabled = false;info_div.innerHTML="璇风偣鍑诲紑濮�";}, 3000 );
+ wsconnecter.wsStop();
+ btnStart.disabled = true;
+ btnConnect.disabled=false;
+ info_div.innerHTML="璇风偣鍑昏繛鎺�";}, 3000 );
rec.stop(function(blob,duration){
console.log(blob);
--
Gitblit v1.9.1