Comments (13)
@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.
@hackingbeauty And it's all back to normal! Thanks a bunch!
from react-mic.
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.
@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.
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.
@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.
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.
@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.
@hackingbeauty I have latest version ([email protected]), no change
from react-mic.
@free2580 good catch. Can you upgrade to [email protected] and verify that it works for you? I just pushed a patch.
from react-mic.
@hackingbeauty How can we send the recorded audio to the flask api and then store it to mysql?
from react-mic.
@Alina03 Yes, you can do whatever you want with the audio.
from react-mic.
My question was how can we send the recorded audio to the flask api?
from react-mic.
Related Issues (20)
- Is there any option to Pause the Recording ? HOT 1
- window is undefined HOT 3
- What is the default sample rate in Heartz that it records in? HOT 1
- Unable to set channelCount to 1
- onStop callback not refreshed on componentUpdate HOT 4
- Can't listen to file after downloading to PC
- onStop returns an Object, So how to get Blob that contains Blob data.
- Blobs received in onData function are unusable
- facing type error while testing 'npm run test' in reactjs
- Good morning. I am using react-mic. While using it, I found something strange on window pc, mac pc, and mobile.
- Not working correctly in deployment env HOT 2
- React Mic Gold Website Not Working HOT 8
- How can i upload this blob to firebase storage HOT 2
- Find Frequency from Blobs?
- How to use with typescript project (like NextJs) ? HOT 1
- add a megaphone feature? pls?
- Mic detection
- Doesn't support in react 18.0.x
- Browser audio recording is not supported HOT 2
- How well supported is this package? Is it worth using today?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-mic.