0
点赞
收藏
分享

微信扫一扫

计算机视觉与深度学习实战,Python为工具,基于计算机视觉的自动驾驶应用

蚁族的乐土 2024-06-14 阅读 10

一、需求是点击发送按钮说话获取语音文件发送给后台、鼠标移除即发送,限制时长30s

代码如下

<ttemplete>
 <div class="bottom">
      <el-button type="primary" size="small" @mousedown.native="startRecord" @mouseup.native="stopRecord" @mouseleave.native="stopRecord">
             开始对讲
         </el-button>
       <el-button v-if="isRecording" type="primary" size="small">录音中...</el-button>
    </div>
</templete>
<script>
export deafult{
  data(){
     return{
        isRecording: false,
        mediaRecorder: null,
         chunks: [],
         recordingTimer: null, // 录音定时器
     }
  },
  methods:{
  startRecord() {
        if (!this.isRecording) {
             this.isRecording = true;
             // 初始化录音
             navigator.mediaDevices.getUserMedia({ audio: true })
                 .then(st
举报

相关推荐

0 条评论