Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to get recordingBlob during the record without calling stopRecording() #107

Open
TanachaiAnakewat opened this issue Nov 23, 2023 · 0 comments
Assignees

Comments

@TanachaiAnakewat
Copy link

TanachaiAnakewat commented Nov 23, 2023

Describe the bug
Currently I want to get the recordingBlob every 30 seconds without calling stopRecording(). What I doing now is to call stopRecording and startRecording suddenly after it. However, it took around 1second to continue the recording and the audio between stopRecording and startRecording is not record. Is there any way to do it?

This is my implementation

  const recorderControls = useAudioRecorder();
  
useEffect(() => {
    if (!duringRecord) return;
    if (recorderControls.recordingTime === 30) {
      recorderControls.stopRecording();
    }
    if (recorderControls.recordingTime === 0) {
      recorderControls.startRecording();
    }
  }, [recorderControls.recordingTime]);



  useEffect(() => {
    if (!recorderControls.recordingBlob) return;
    setSecBlob(recorderControls.recordingBlob);
  }, [recorderControls.recordingBlob]);

  useEffect(() => {
    if (!secBlob) return;
    console.log("secBlob:" + secBlob);
    blobToTranscript(secBlob);
  }, [secBlob]);

// how I call the component

 <AudioRecorder
                    // onRecordingComplete={(audioBlob) =>
                    //   blobToTranscript(audioBlob)
                    // }
                    audioTrackConstraints={{
                      noiseSuppression: true,
                      echoCancellation: true,
                    }}
                    showVisualizer={true}
                    recorderControls={recorderControls}
                    classes={{
                      AudioRecorderClass: "recorder",
                      AudioRecorderTimerClass: "display-none",
                      AudioRecorderStatusClass:
                        "content status bg-gray-200 p-2 rounded",
                      AudioRecorderStartSaveClass: "display-none",
                      AudioRecorderPauseResumeClass: "display-none",
                      AudioRecorderDiscardClass: "display-none",
                    }}

Expected behavior
I want to let the recorder always record the audio. During the recoding, I want to get the 30sec chunks of the blob. ie 0-30sec, 30-60sec etc. continuously

Package info (please complete the following information):

  • Version 2.1.2
  • Nextjs 13.5.2
@TanachaiAnakewat TanachaiAnakewat changed the title Is there a way to get recordingBlob during the record Is there a way to get recordingBlob during the record without calling stopRecording() Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants