-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
How can I get the blob file (i.e recorder voice) to send the server #188
Comments
I would suggest using bt.onclick = function(){
var xhr=new XMLHttpRequest();
xhr.onload=function(e) {
if(this.readyState === 4) {
console.log("Server returned: ",e.target.responseText);
}
};
var fd=new FormData();
fd.append("audio_data",blob, "filename.wav");
xhr.open("POST","upload.php",true);
xhr.send(fd);
} Source: https://addpipe.com/blog/using-recorder-js-to-capture-wav-audio-in-your-html5-web-site/ |
works nicely in flask: and in app.py: @app.route('/messages', methods = ['POST']) |
I am having an issue with upload.php not being found. The public directory is available and the file(blob) is found if I copy the download link. This is the only PHP file in my entire stack so I am unsure if I need another PHP file to initialize it or if it is to be referenced in the main app.js. |
It's working perfect. Thank you so Much! |
i got many errors while trying it , please is there a clean way to do it ? |
@maneeshrao66 you can do it using xhr request. I used it with C# as follows Controller Name: Evaluation C# Method:
JS code:
Hope this helps |
Thanks, i just tried the first solution and it worked perfectly with flask . i had problems elsewhere but the senData worked just fine . , thank you for your reply |
How do i call a function to access this data @aschuss |
works nicely in flask: and in app.py: @app.route('/messages', methods = ['POST']) The recorder is not opening for me |
how to automatically download the blob file to the directory that has been specified? |
I found it here is an implementation using django
// app.js
// get cookie csrf from django
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
// using fetch
function sendData(blob) {
const csrf_token = getCookie('csrftoken')
fetch('messages/', {
headers: {"X-CSRFToken": csrf_token},
method: 'post',
body: blob,
});
console.log('success')
} |
Hi, I have successfully recorded the audio voice. Now I want to send the recorded voice to server. So I have created a button i.e save and trying to get the recorded voice.
Where should I find the value which are recorded?
I tried below code:-
The text was updated successfully, but these errors were encountered: