收藏
回答

开发者工具中测试RecorderManager录制的音频时长异常?

编写了一个简单的录制音频的页面,功能是在页面加载的时候开始录音,倒计时20s之后停止录音并将录音上传到云存储。在windows开发者平台进行测试,当我从云存储下载临时的录制文件到本地的时候,录制的音频文件时长异常,音频文件大小是正常的为100k左右,以下是时长异常的截图和代码片段:

const recorderManager = wx.getRecorderManager();

Page({
  data: {
    countdown20,
  },
  onLoadfunction () {
    this.startRecording();
    this.startCountdown();
  },

  startRecordingfunction () {
    const options = {
      format"mp3",
      sampleRate22050,
      numberOfChannels1,
      encodeBitRate124000,
      frameSize50,
    };
    recorderManager.start(options);
  },

  startCountdownfunction () {
    let countdown = 20;
    const countdownInterval = setInterval(() => {
      countdown--;
      this.setData({ countdown: countdown });
      if (countdown === 0) {
        clearInterval(countdownInterval);
        this.stopRecording();
      }
    }, 1000);
  },
  stopRecordingfunction () {
    recorderManager.stop();
    recorderManager.onStop((res) => {
      console.log('录音结束', res);
      const { tempFilePath } = res;
      wx.cloud.uploadFile({
        cloudPath'recordedfile_user.mp3',
        filePath: tempFilePath
      })
      setTimeout(function() {
        wx.navigateTo({
          url`/pages/recognize/recognize`,
        });
      }, 3000); // 延时3秒
    });
  }
})   
回答关注问题邀请回答
收藏

1 个回答

  • Demons
    Demons
    2023-03-30

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2023-03-30
    有用
    回复 1
    • qqf
      qqf
      2023-09-20
      除了这句还会什么?
      2023-09-20
      回复
登录 后发表内容