asr语音识别
前端负责语音识别有长语音识别和实时语音识别,有基于js和jquery做的简单demo,这里是vue+ js-audio-recorder。第三方插件给了丰富的功能,包括采样样本,采样率,声道,浏览器录音权限等。
`
录音上传
<div style="font-size: 14px">
<h3>录音时长:{
{ recorder && recorder.duration.toFixed(4) }}</h3>
<el-button type="primary" @click="handleStart">开始录音</el-button>
<el-button type="info" @click="handlePause">暂停录音</el-button>
<el-button type="success" @click="handleResume">继续录音</el-button>
<el-button type="warning" @click="handleStop">停止录音</el-button>
<h3>
播放时长:{
{
recorder &&
(playTime > recorder.duration
? recorder.duration.toFixed(4)
: playTime.toFixed(4))
}}
</h3>
<br />
<div class="bo">
<el-button type="primary" @click="handlePlay">播放录音</el-button>
<el-button type="info" @click="handlePausePlay">暂停播放</el-button>
<el-button type="success" @click="handleResumePlay">继续播放</el-button>
<el-button type="warning" @click="handleStopPlay">停止播放</el-button>
<el-button type="error" @click="handleDestroy">销毁录音</el-button>
<el-button type="info" @click="downWAV">下载WAV</el-button>
<el-button type="info" @click="downPCM">下载pcm</el-button>
<el-button type="primary" @click="uploadRecord">上传</el-button>
<el-button type="success" @click="getResults">识别结果</el-button>
</div>
<br />
<br />
<textarea
name=""
id="textarea"
style="width: 100%; height: 100px"
cols="30"
rows="10"
v-model="result"
/>
</div>
`
<script>
import Recorder from "js-audio-recorder";
//import MyRecorder from '../js/MyRecorder'
import {
v4 as uuidv4 } from "uuid";
uuidv4();
//const baseURL = "http://10.34.23.133:8899/asr/non_real";
export default {
data() {
return {
recorder: null,
playTime: 0,
timer: null,
src: null,
sessionId: "",
audio: "",
data: "",
result: "",
};
},
created() {
},
mounted() {
this.dataRecorder = this.data;
},
methods: {
// 开始录音
handleStart() {
const uuid = require("uuid");
this.sessionId = uuid.v4();
console.log(this.sessionId);
this.recorder = new Recorder({
sampleBits