Merge pull request #2091 from zh794390558/demo

[demo] fix demo
pull/2096/head
YangZhou 3 years ago committed by GitHub
commit a0d1888c0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -66,7 +66,7 @@
</div> </div>
</div> </div>
<script> <script>
var wenetWs = null var ws = null
var timeLoop = null var timeLoop = null
var result = "" var result = ""
$(document).ready(function () { $(document).ready(function () {
@ -76,18 +76,18 @@
function openWebSocket(url) { function openWebSocket(url) {
if ("WebSocket" in window) { if ("WebSocket" in window) {
wenetWs = new WebSocket(url) ws = new WebSocket(url)
wenetWs.onopen = function () { ws.onopen = function () {
console.log("Websocket 连接成功,开始识别") console.log("Websocket 连接成功,开始识别")
wenetWs.send(JSON.stringify({ ws.send(JSON.stringify({
"signal": "start" "signal": "start"
})) }))
} }
wenetWs.onmessage = function (_msg) { parseResult(_msg.data) } ws.onmessage = function (_msg) { parseResult(_msg.data) }
wenetWs.onclose = function () { ws.onclose = function () {
console.log("WebSocket 连接断开") console.log("WebSocket 连接断开")
} }
wenetWs.onerror = function () { console.log("WebSocket 连接失败") } ws.onerror = function () { console.log("WebSocket 连接失败") }
} }
} }
@ -104,7 +104,7 @@
var blob = blobOrNull var blob = blobOrNull
var encTime = blob.encTime var encTime = blob.encTime
var reader = new FileReader() var reader = new FileReader()
reader.onloadend = function () { wenetWs.send(reader.result) } reader.onloadend = function () { ws.send(reader.result) }
reader.readAsArrayBuffer(blob) reader.readAsArrayBuffer(blob)
} }
} }
@ -142,7 +142,7 @@
} }
function stopRecording() { function stopRecording() {
wenetWs.send(JSON.stringify({ "signal": "end" })) ws.send(JSON.stringify({ "signal": "end" }))
SoundRecognizer.recordClose() SoundRecognizer.recordClose()
$('#endBtn').add($('#timeBox')).removeClass('show') $('#endBtn').add($('#timeBox')).removeClass('show')

Loading…
Cancel
Save