()
| 462 | |
| 463 | |
| 464 | function stop() { |
| 465 | var chunk_size = new Array( 5, 10, 5 ); |
| 466 | var request = { |
| 467 | "chunk_size": chunk_size, |
| 468 | "wav_name": "h5", |
| 469 | "is_speaking": false, |
| 470 | "chunk_interval":10, |
| 471 | "mode":getAsrMode(), |
| 472 | }; |
| 473 | console.log(request); |
| 474 | if(sampleBuf.length>0){ |
| 475 | wsconnecter.wsSend(sampleBuf); |
| 476 | console.log("sampleBuf.length"+sampleBuf.length); |
| 477 | sampleBuf=new Int16Array(); |
| 478 | } |
| 479 | wsconnecter.wsSend( JSON.stringify(request) ); |
| 480 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | |
| 486 | // 控件状态更新 |
| 487 | |
| 488 | isRec = false; |
| 489 | info_div.innerHTML="发送完数据,请等候,正在识别..."; |
| 490 | |
| 491 | if(isfilemode==false){ |
| 492 | btnStop.disabled = true; |
| 493 | btnStart.disabled = true; |
| 494 | btnConnect.disabled=true; |
| 495 | //wait 3s for asr result |
| 496 | setTimeout(function(){ |
| 497 | console.log("call stop ws!"); |
| 498 | wsconnecter.wsStop(); |
| 499 | btnConnect.disabled=false; |
| 500 | info_div.innerHTML="请点击连接";}, 3000 ); |
| 501 | |
| 502 | |
| 503 | |
| 504 | rec.stop(function(blob,duration){ |
| 505 | |
| 506 | console.log(blob); |
| 507 | var audioBlob = Recorder.pcm2wav(data = {sampleRate:16000, bitRate:16, blob:blob}, |
| 508 | function(theblob,duration){ |
| 509 | console.log(theblob); |
| 510 | var audio_record = document.getElementById('audio_record'); |
| 511 | audio_record.src = (window.URL||webkitURL).createObjectURL(theblob); |
| 512 | audio_record.controls=true; |
| 513 | //audio_record.play(); |
| 514 | |
| 515 | |
| 516 | } ,function(msg){ |
| 517 | console.log(msg); |
| 518 | } |
| 519 | ); |
| 520 | |
| 521 |
no test coverage detected
searching dependent graphs…