Coder Social home page Coder Social logo

Comments (13)

hackingbeauty avatar hackingbeauty commented on May 26, 2024 1

@daas-ankur-shukla,

You need to pass a callback to the onStop prop of React-Mic. Like this:

onStopCallback(recordedBlob) {
  /* Do something with recordedBlob here */
}

<ReactMic
  record={this.state.record}
  onStop={this.onStopCallback} />

The callback will receive one argument when the user stops recording which is the recorded BLOB. This BLOB is what you send to your API endpoint for processing.

from react-mic.

fridaland avatar fridaland commented on May 26, 2024 1

@hackingbeauty And it's all back to normal! Thanks a bunch!

from react-mic.

trops avatar trops commented on May 26, 2024

I found the blob to have no data in it except for the type, etc.

I had to use a different piece of code to get the data of the actual audio file and still testing this now.

var reader = new FileReader();
          reader.onload = function(event) {
            var fd = {};
            fd["fname"] = "test.wav";
            fd["data"] = event.target.result;
            callback(fd);
          };
          reader.readAsDataURL(audioBlob);

I was sending my data to an endpoint that uploads to S3, and it fails using just the blob. When I convert the data as shown above, it creates the file.

I am now trying to figure out the format which looks like audio/webm based on the file data that gets generated. I really like the library, just spending hours after I recorded trying to figure out how to USE the recording and any details about it.

from react-mic.

thisisashukla avatar thisisashukla commented on May 26, 2024

@trops hi. with whatever little experience i have had with this component. I got the data in the blob as mentioned by @hackingbeauty in his comment. My issue however was about the format in which the blob was generated. It will always be generated in the default format.

from react-mic.

trops avatar trops commented on May 26, 2024

I haven't been able to. I am uploading to my endpoint then my endpoint handles the upload to S3, I think that is the issue. So I am still left with corrupt audio files for whatever reason. Really wish there was a straightforward way of saving the files.

Edit: Turns out it works if you upload DIRECT to s3 using the AWS S3 SDK and not using a proxy endpoint like I was using. I still haven't figured that one out yet, but for my purposes I don't need to worry about it for now, but would be curious how it works to send the raw data to an endpoint and that endpoint upload it to S3...

var params = { 
        Body: <audioBlob>,
        Bucket: '<BUCKET_NAME>', 
        Key: <filename>,
        ContentType: 'audio/wav',
      };
      return new Promise(function(resolve, reject) {
        s3.putObject(params, function(err, data) {
          if(err) {
            console.log(err); 
            return reject(err);
          } else {
            console.log(data);
            return resolve(data);
          }
        });
      });

from react-mic.

akigmm avatar akigmm commented on May 26, 2024

@hackingbeauty When we call the API from index.js the onStop prop has to be added inside the render which is giving the error of cannot change the transition because of which the callback is never happening

from react-mic.

fridaland avatar fridaland commented on May 26, 2024

Any Idea why the sound wave stroke line only works the first recording? Still records, but I have to refresh to actually see the sound wave again. Any advice?

from react-mic.

hackingbeauty avatar hackingbeauty commented on May 26, 2024

@free2580 this problem was already fixed. Please update your version of React-Mic to the latest version, and let me know if everything works for you as expected.

from react-mic.

fridaland avatar fridaland commented on May 26, 2024

@hackingbeauty I have latest version ([email protected]), no change

from react-mic.

hackingbeauty avatar hackingbeauty commented on May 26, 2024

@free2580 good catch. Can you upgrade to [email protected] and verify that it works for you? I just pushed a patch.

from react-mic.

Alina03 avatar Alina03 commented on May 26, 2024

@hackingbeauty How can we send the recorded audio to the flask api and then store it to mysql?

from react-mic.

hackingbeauty avatar hackingbeauty commented on May 26, 2024

@Alina03 Yes, you can do whatever you want with the audio.

from react-mic.

Alina03 avatar Alina03 commented on May 26, 2024

My question was how can we send the recorded audio to the flask api?

from react-mic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.