# Personal Web Api to get Decibels from an audio

**URL:** https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441
**Category:** Web API's
**Created:** [May 2, 2024, 4:01pm UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441 "2024-05-02T16:01:54Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![tapionpad4x0](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tapionpad4x0](https://community.thunkable.com/u/tapionpad4x0)
#### Post date: [May 2, 2024, 4:01pm UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/1 "2024-05-02T16:01:54Z")

</div>

I’m trying to create an app that record an audio in thunkable, save it with the cloudinary url in the format “.wav”, send it to a flask server located in my online website with pythonanywhere, download locally the audio, analyze it with Librosa and return the decibels, but it doesn’t work, any suggestions?

THUNKABLE CODE:

 ![Thunkable - Google Chrome 02_05_2024 17_59_39](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/a/7a3f85a9bd19fdb5555d3848eb7152d33f9015b5.png)

SOURCE CODE of the website:

````auto

from flask import Flask, request, jsonify
import requests
import librosa

app = Flask( __name__ )

@app.after_request
def add_cors_headers(response):
    response.headers.add('Access-Control-Allow-Origin', '*')
    return response
    
@app.route('/upload', methods=['POST'])
def upload():
    if request.method == 'POST':
        # Ottieni l'URL dell'audio dal body della richiesta
        audio_url = request.json.get('audio_url')

        # Scarica l'audio dall'URL e salvalo localmente
        response = requests.get(audio_url)
        with open('audio.wav', 'wb') as f:
            f.write(response.content)

        # Carica l'audio utilizzando LibROSA
        y, sr = librosa.load('audio.wav')

        # Calcola i decibel dell'audio utilizzando LibROSA
        decibels = librosa.amplitude_to_db(librosa.magphase(librosa.stft(y))[0])

        # Restituisci i decibel come risposta JSON
        return jsonify({'decibels': decibels.tolist()})```
````

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [May 2, 2024, 5:02pm UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/2 "2024-05-02T17:02:48Z")

</div>

> [@tapionpad4x0](#):
>
> it doesn’t work

Which part doesn’t work? Which parts do work? Are you getting an error message?

---

<div class="post-metadata">

### Author: ![tapionpad4x0](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tapionpad4x0](https://community.thunkable.com/u/tapionpad4x0)
#### Post date: [May 2, 2024, 5:18pm UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/3 "2024-05-02T17:18:05Z")

</div>

Yea Sorry, the server work well, It gives the correct log and so on…  
I think the problem is in the web api call or in the convertion of audio url, because the error is  
“the browser or proxy send a request that this server could not understand” or “failed tò fetch data”. Can u revise if both code and their relation works well?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [May 2, 2024, 5:48pm UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/4 "2024-05-02T17:48:15Z")

</div>

I’m not familiar with flask servers but have you tested this on a mobile device? Do you get the same error message?  
  
·····················································································································  
Need help? [How to Ask Great Questions](https://community.thunkable.com/t/how-to-ask-great-questions-v2-0/2689983) ✨ [Debugging A Project](https://community.thunkable.com/t/debugging-in-thunkable-x-video/849471) ✨ [API JSON Tutorial](https://community.thunkable.com/t/api-json-tutorial-video/1140575)

Want to hire a Certified Thunkable Expert? [Elevate your app with Tatiang on Fiverr](https://www.fiverr.com/s/726B4a)

---

<div class="post-metadata">

### Author: ![tapionpad4x0](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tapionpad4x0](https://community.thunkable.com/u/tapionpad4x0)
#### Post date: [May 2, 2024, 6:36pm UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/5 "2024-05-02T18:36:28Z")

</div>

Yea on mobile i get “the browser or proxy send a request that this server could not understand". Anyone familiar with flask?

---

<div class="post-metadata">

### Author: ![tapionpad4x0](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tapionpad4x0](https://community.thunkable.com/u/tapionpad4x0)
#### Post date: [May 2, 2024, 6:50pm UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/6 "2024-05-02T18:50:01Z")

</div>

This is the response from the web api:

```auto
<!doctype html>
<html lang=en>
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>

```

---

<div class="post-metadata">

### Author: ![tapionpad4x0](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tapionpad4x0](https://community.thunkable.com/u/tapionpad4x0)
#### Post date: [May 2, 2024, 8:30pm UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/7 "2024-05-02T20:30:27Z")

</div>

Someone good to work with Flask server in Thunkable?

---

<div class="post-metadata">

### Author: ![pacecode](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/pacecode/32/209017_2.png) [@pacecode](https://community.thunkable.com/u/pacecode)
#### Post date: [May 3, 2024, 1:09am UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/8 "2024-05-03T01:09:55Z")

</div>

Welcome Back!  
First of all, your Blocks are Incorrect,  
In headers, you must not put that JSON from Object.  
These Blocks Work:

 ![Screenshot 2024-05-03 at 6.32.26 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/9/f96bd2a98fc1ee2f424f7fd4d042ab7c53c3bbd9.png)  
But when you test it in Thunkable Live test or Web Preview, it’ll Crash Because the JSON Response is too Large with more than 200k 💀 values in a single List ( 3.57 MB) when I tested it on Postman.  
 ![Screenshot 2024-05-03 at 6.31.48 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/0/c02786ea1dc2ea74fea811cc2585e0319aadd178.png)  
 ![Screenshot 2024-05-03 at 6.32.01 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/6/366e77a572544fd3f0414078a69cd1744a278ccf.jpeg)  
Thunkable can’t Manage these Big Files, there are thousands of Objects inside the Response and It’ll be hard to Figure out a way to do it in Thunkable.  
You can DM me as I can Figure out a way to Fix it in Thunkable.

* * *

Want to hire a Certified Thunkable Expert? [| Get Help and Solve Issues of your thunkable Projects with whoocoder, HIRE NOW ON FIVERR! |](https://pro.fiverr.com/certified/thunkable?utm_source=fiverr_certified&utm_medium=homepage&utm_campaign=certified_home&service=thunkable-project&active_expert_id=147498421)

Thanks, whoocoder

---

<div class="post-metadata">

### Author: ![tapionpad4x0](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tapionpad4x0](https://community.thunkable.com/u/tapionpad4x0)
#### Post date: [May 3, 2024, 5:36am UTC](https://community.thunkable.com/t/personal-web-api-to-get-decibels-from-an-audio/2981441/9 "2024-05-03T05:36:46Z")

</div>

Thank u, I DM u.
