# How to use Inference API to perform speech recognition

**URL:** <https://discuss.huggingface.co/t/how-to-use-inference-api-to-perform-speech-recognition/111585>\
**Category:** Beginners\
**Created:** [October 12, 2024, 4:44pm UTC](https://discuss.huggingface.co/t/how-to-use-inference-api-to-perform-speech-recognition/111585 "2024-10-12T16:44:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kod33o](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@kod33o](https://discuss.huggingface.co/u/kod33o)\
**Post date:** [October 12, 2024, 4:44pm UTC](https://discuss.huggingface.co/t/how-to-use-inference-api-to-perform-speech-recognition/111585/1 "2024-10-12T16:44:06Z")

</div>

Hi everyone.  
I am working on a custom project that requires speech recognition.  
I need to set up speech recognition with whisper, but my project is just for internal use of my family.

In a realistic scenario, I am not making more than 100 requests per-day, and each request would use the model for 1-10 minutes.

I set up an Inference Endpoint, thinking I would be billed only when my requests happen, but the model appears to always be in a “Running” state, so I am just billed 0.50 per hour since I created it which is waaaaay too much for me, completely unbearable.

So I tried to use the API:

```auto
import os

import requests
from dotenv import load_dotenv

load_dotenv()

API_TOKEN = os.environ.get('HF_TOKEN')

audio_file_path = "sample_data/10_min_meeting.wav"

headers = {"Authorization": f"Bearer {API_TOKEN}"}
API_URL = "https://api-inference.huggingface.co/models/openai/whisper-large-v3"

def query(filename):
    with open(filename, "rb") as f:
        data = f.read()
    response = requests.request("POST", API_URL, headers=headers, data=data)
    return response

data = query(audio_file_path)
print(data)

```

But this only leads to a 413 ‘Payload Too Large’ Error.

What I need is just to run the model to perform the speech recognition remotely, since I do not have the hardware to run it on my own.  
I am willing to pay for pro or for paid services if they let me achieve what I want in a feasible manner (0.5€ per hour is not feasible, I would like to stay under 50€/month)

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [October 12, 2024, 10:42pm UTC](https://discuss.huggingface.co/t/how-to-use-inference-api-to-perform-speech-recognition/111585/2 "2024-10-12T22:42:14Z")

</div>

The default seems to be up to 2 MB. However, model authors and Spaces authors have the means to increase the limit…?  
I also heard that the limit is relaxed when using Inference Endpoint.

> <https://github.com/huggingface/text-embeddings-inference/issues/50>
>
> I get this "Failed to buffer the request body: length limit exceeded" when use r…equests.post
> is my inputs too large?

> **[sanchit-gandhi/whisper-jax · Issue: 413 Payload Too Large](https://huggingface.co/spaces/sanchit-gandhi/whisper-jax/discussions/71)**
>
> I'm trying to upload an 8 MB mp3 file with an 8-minute conversation, and I see 413 Payload Too Large error in the Chrome inspector.
