Skip to first unread message

G10DRAS

unread,
Jun 3, 2018, 10:39:44 PM6/3/18
to MIT App Inventor Forum
What I have done so far in App Inventor

1. Record voice using SoundRecorder. [works]
2. Play it using Player. [works]
3. Post it to http server. [not working].

I have done same thing using Java Script in browser and it works.

Java Script:-

function uploadToServer(blobOrFile) {
   
var username = "xxxxxx";
   
var password = "xxxxxxxxx";

   
var formData = new FormData();
    formData
.append('file', blobOrFile, 'output.wav');
   
var request = new XMLHttpRequest();
    request
.addEventListener("load", reqListener);
    request
.open("POST", "/commands", true, username, password);
    request
.send(formData);
}



Here is the HTTP Flask Server code which handles file upload.
 
   """ Route that will process audio """
   
@app.route('/commands', methods=['POST'])
   
@requires_auth
   
def process_commands():
       
"""Get user submitted audio file, save, process and then delete."""
       
       
print request.headers
       
print request.__dict__
       
       
print request.args
       
print request.form
       
print request.files
       
       
""" Get the name of the uploaded file """
        file
= request.files['file']

Trying to do similar using App Inventor, but dont know where is the problem.
I want to do the JS equilavant thing in App Inventor but didnt get any example.

Have attached the Blocks


Taifun

unread,
Jun 4, 2018, 1:17:24 PM6/4/18
to MIT App Inventor Forum
are you getting an error message in the GotText event?
see also 

g10dras

unread,
Jun 4, 2018, 7:38:10 PM6/4/18
to mitappinv...@googlegroups.com
Yes I am getting following error message in GotText

<title> 400 Bad Request </title>
<h1> Bad Request </h1>
<p> The Browser (or proxy) sent a request that this server could not understand. </p>

Unfortunatly I am not using PHP on server side, I am using python Flask framework.

Taifun

unread,
Jun 4, 2018, 7:43:31 PM6/4/18
to MIT App Inventor Forum
I guess, it does not work, because the web component does not support multipart/formdata
Taifun

g10dras

unread,
Jun 4, 2018, 7:48:19 PM6/4/18
to mitappinv...@googlegroups.com
Is there any work around ?
I just want to record and upload a file to server that's all.


Note:-
It seems App Inventor app sends chunked encoded requests, and WSGI does not support chunked request encoding.
Web component in App Inventor does not support multipart/formdata, which is supported by WSGI.


Any plan to support "multipart/formdata" in App Inventor ?

g10dras

unread,
Jun 5, 2018, 2:04:15 AM6/5/18
to MIT App Inventor Forum
OK I managed to handle "chunked encoded requests" from App Inventor App at my WSGI Server side.

Sound recorded by Sound Recorder is in .3gp format and of poor quality.
Is there any way to record sound in wave format ?

Taifun

unread,
Jun 5, 2018, 9:58:08 AM6/5/18
to MIT App Inventor Forum
Is there any way to record sound in wave format ?
you might want to check the extension directory https://puravidaapps.com/extensions.php
Taifun

g10dras

unread,
Jun 7, 2018, 9:53:25 AM6/7/18
to MIT App Inventor Forum
Seems no free wav file recorder available for App Inventor.
Never mind I managed to convert 3gp to wav at server side and thats also working fine.

Can I get SoundRecorder extension source code ?
I will try to modify it so that it will also record wav file.

Taifun

unread,
Jun 7, 2018, 10:23:14 AM6/7/18
to MIT App Inventor Forum
which sound recorder extension are you talking about?
you can find the sources of the sound recorder component in the MIT App Inventor sources

Taifun

g10dras

unread,
Jun 9, 2018, 9:36:03 AM6/9/18
to MIT App Inventor Forum
This one

http://community.appybuilder.com/t/record-wave-file-extension-paid/3946?u=taifun

I am writing my own "record-wave-file-extension", guess it will not take more than 2 days.

Taifun

unread,
Jun 9, 2018, 10:53:28 AM6/9/18
to MIT App Inventor Forum
I am writing my own "record-wave-file-extension", guess it will not take more than 2 days.
great! keep us updated about your progress...

http://community.appybuilder.com/t/record-wave-file-extension-paid/3946?u=taifun
btw. for feature requests of an extension, you might want to ask the author of the extension, which is Andres in this case...

Taifun

g10dras

unread,
Jun 9, 2018, 11:17:09 AM6/9/18
to MIT App Inventor Forum

Well almost finished, just need a final touch



G10DRAS

unread,
Jun 10, 2018, 4:59:19 AM6/10/18
to MIT App Inventor Forum
Reply all
Reply to author
Forward
0 new messages