收藏
回答

如何使用 onFrameRecorded?

    this.recorderManager.start({

      duration: 60000,

      frameSize: 5,

      format: 'pcm',

      sampleRate: 8000,

      numberOfChannels: 1

    });


    this.recorderManager.onFrameRecorded((res) => {

      console.log('[Recorder] Frame recorded, bufferSize:', res.frameBuffer.byteLength);

      const base64 = wx.arrayBufferToBase64(res.frameBuffer);

      this.recordClient.sendChunk(this.currentChunkIndex, base64);

      this.currentChunkIndex++;

      this.setData({

        totalChunks: this.data.totalChunks + 1

      });

    });


回答关注问题邀请回答
收藏

2 个回答

  • 白菜、
    白菜、
    04-27

    1、合成后只有电流声没有其他声音

    2、后端合成使用的FFmpeg合成

     ffmpeg()

        .input(pcmPath)

        .inputFormat('mulaw')

        .inputOptions(['-ar', '8000', '-ac', '1'])

        .output(mp3Path)

        .format('mp3')

        .on('end', () => {

          if (fs.existsSync(pcmPath)) {

            fs.unlinkSync(pcmPath);

          }

          console.log(`[Merger] PCM converted to MP3: ${mp3Path}`);

          callback(null, mp3Path);

        })

        .on('error', (err) => {

          console.error('[Merger] FFmpeg convert error:', err.message);

          callback(err);

        })

        .run();

    3、版本库为3.15.2系统为 windows






    04-27
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    04-27
    有用
    回复
登录 后发表内容