From b57d8afba089948f1dae4cd27296904acac70214 Mon Sep 17 00:00:00 2001
From: zhaomingwork <61895407+zhaomingwork@users.noreply.github.com>
Date: 星期三, 28 六月 2023 16:48:57 +0800
Subject: [PATCH] add html5 not auto play wav and manually authorization (#681)
---
funasr/runtime/html5/static/index.html | 4 +++-
funasr/runtime/html5/static/main.js | 30 +++++++++++++++++++++++++++---
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/funasr/runtime/html5/static/index.html b/funasr/runtime/html5/static/index.html
index 23d6fec..783729e 100644
--- a/funasr/runtime/html5/static/index.html
+++ b/funasr/runtime/html5/static/index.html
@@ -19,7 +19,9 @@
<div class="div_class_recordControl">
asr鏈嶅姟鍣ㄥ湴鍧�(蹇呭~):
<br>
- <input id="wssip" type="text" style=" width: 100%;height:100%" value="wss://127.0.0.1:10095/"/>
+ <input id="wssip" type="text" onchange="addresschange()" style=" width: 100%;height:100%" value="wss://127.0.0.1:10095/"/>
+ <br>
+ <a id="wsslink" href="#" onclick="window.open('https://127.0.0.1:10095/', '_blank')"><div id="info_wslink">鎵嬪伐鎺堟潈wss://127.0.0.1:10095/</div></a>
<br>
<br>
<div style="border:2px solid #ccc;">
diff --git a/funasr/runtime/html5/static/main.js b/funasr/runtime/html5/static/main.js
index 04d22a9..445ef50 100644
--- a/funasr/runtime/html5/static/main.js
+++ b/funasr/runtime/html5/static/main.js
@@ -31,6 +31,9 @@
btnConnect= document.getElementById('btnConnect');
btnConnect.onclick = start;
+
+var awsslink= document.getElementById('wsslink');
+
var rec_text=""; // for online rec asr result
var offline_text=""; // for offline rec asr result
@@ -45,6 +48,27 @@
var totalsend=0;
+
+var now_ipaddress=window.location.href;
+now_ipaddress=now_ipaddress.replace("https://","wss://");
+now_ipaddress=now_ipaddress.replace("static/index.html","");
+var localport=window.location.port;
+now_ipaddress=now_ipaddress.replace(localport,"10095");
+document.getElementById('wssip').value=now_ipaddress;
+addresschange();
+function addresschange()
+{
+
+ var Uri = document.getElementById('wssip').value;
+ document.getElementById('info_wslink').innerHTML="鎵嬪伐鎺堟潈"+Uri;
+ Uri=Uri.replace(/wss/g,"https");
+ console.log("addresschange uri=",Uri);
+
+ awsslink.onclick=function(){
+ window.open(Uri, '_blank');
+ }
+
+}
upfile.onclick=function()
{
btnStart.disabled = true;
@@ -77,7 +101,7 @@
var audio_record = document.getElementById('audio_record');
audio_record.src = (window.URL||webkitURL).createObjectURL(audioblob);
audio_record.controls=true;
- audio_record.play();
+ //audio_record.play(); //not auto play
}
function start_file_send()
{
@@ -223,7 +247,7 @@
stop();
console.log( 'connecttion error' );
- alert("杩炴帴鍦板潃"+document.getElementById('wssip').value+"澶辫触,璇锋鏌sr鍦板潃鍜岀鍙o紝骞剁‘淇漢5鏈嶅姟鍜宎sr鏈嶅姟鍦ㄥ悓涓�涓煙鍐呫�傛垨鎹釜娴忚鍣ㄨ瘯璇曘��");
+ alert("杩炴帴鍦板潃"+document.getElementById('wssip').value+"澶辫触,璇锋鏌sr鍦板潃鍜岀鍙c�傛垨璇曡瘯鐣岄潰涓婃墜鍔ㄦ巿鏉冿紝鍐嶈繛鎺ャ��");
btnStart.disabled = true;
btnStop.disabled = true;
btnConnect.disabled=false;
@@ -329,7 +353,7 @@
var audio_record = document.getElementById('audio_record');
audio_record.src = (window.URL||webkitURL).createObjectURL(theblob);
audio_record.controls=true;
- audio_record.play();
+ //audio_record.play();
} ,function(msg){
--
Gitblit v1.9.1