API call - sending audio recording with POST. Need help!

Hi guys,

so I try to setup API with Speechace (its a an api that compares your pronunciation of a word with someone with english accent) for that I need a recording of someone speaking. So I have that (audio recording plugin) but I cant make a API call because in API connector the required value for key user_audio_file is @/path/to/recording.wav.

but my path is: https://s3.amazonaws.com/appforest_uf/f1571162364113x213347206138684960/apple.wav

After email exchange with Speechace guys…
“You need to be sure the client you use can grab the audio blob content and pass it as a form_data field. I don’t believe @ with an S3 url works for any of the common tools.”

Can it be done?

documentation for API: https://docs.speechace.com/?version=latest

Screen from my api connector

It wants the audio file to be “local” I think. That is what the @ means in Curl.

So …

 --form "user_audio_file=@/some/path/to/afile.wav

Is…

 Key: user_audio_file Value : some/path/to/afile.wav

…in Bubble terms which is not possible as we don’t have local storage.

Had a similar issue with posting images to twitter that were on S3.

Ended up having to write a Server Side Plugin to pull the URL into the Plugin and then send that.

1 Like

Thank you @NigelG

Yes, that’s the problem :frowning:

Blockquote Ended up having to write a Server Side Plugin to pull the URL into the Plugin and then send that.

Would you be so kind and explain that in more detail?

You need to write some node.js code that pulls in the URL using the request module …

Specifically, you need to create a Server Side Plugin.

This is what the twitter one looks like …

function(properties, context) {
    console.log('Starting up');

    const Twitter = require('twitter');
    const request = require('request').defaults({ encoding: null });


    const client = new Twitter({
        consumer_key: 'keykeykey',
        consumer_secret: 'secretsecret',
        access_token_key: properties.access_token,
        access_token_secret: properties.access_token_secret
    });

    const url = properties.image;

    return context.async( async function(cb) {

        request.get({ url: url }, function(e, r, b) {
            if(!e) {

                client.post('media/upload', {media: b}, function (error, media, response) {
                    if (error) console.log('Error: ', error);
                    // console.log('Media: ' + media.media_id_string);
                    
                    const status = {
                    status: properties.tweet,
                    media_ids: media.media_id_string // Pass the media id string
                	}
                    
                    client.post('statuses/update', status, function (error, tweet, response) {
                    if (!error) {
                        console.log(tweet);

                    			}
                	});
                    
                    cb(null);
                });
            }
         });
     });

}
1 Like

Thank you so much @NigelG.

I will look into that.

Last question: do you think it will work with audio file?

Yes. You will need to replace the twitter API part with the call your API. I had a quick look and there is no pre-built package for Speechace.

It needs a bit of coding knowledge however.

Yes I know. I know someone who could help with that :slight_smile:

Thanks again!

Hi @b.paluch, and welcome to Bubble.

You have another option with Integromat. Send your audio file to Integromat API, convert it from base64 to binary, and then return it to Speechace. Conversion is not required if it is a binary file. The whole thing should look like this. Non-programming time: 15 min.

In this example I saved also the file on S3 (so you can remove that step).

Integromat site

Hey @JohnMark!

Looks like a great solution. I will look into it. Thank you!

1 Like

Oh that is very interesting. So Integromat has internal storage to upload the file so that the API can refer to a local file rather than a URL ?

@JohnMark

it is possible to make that scenario public? or share it with me?

Hi Nigel, yes Integromat has internal storage and refer to a local file.

Hi @b.paluch,

Here some examples. Give a try, and let me know.

The webhook you need to point your recorder audio file

If you file is base64 (like here an m4a file), then you have to convert it to binary file.

here the conversion

and finally

The Integromat staff will help you if you need it > Integromat Automation

Good luck with your project.

John

PS: You can asked Integromat @arpit.choudhury to create a module for SpeechAce :wink:

1 Like

:star_struck:

1 Like

Thank you very much @JohnMark.

I will try to implement it over the weekend.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.