import io import librosa from transformers import pipeline from fastapi import FastAPI, File, UploadFile app = FastAPI() pipe = pipeline(model="pollitoconpapass/whisper-small-finetuned") @app.post("/transcribe-whisper") async def transcribe(audio: UploadFile = File(...)): contents = await audio.read() buffer = io.BytesIO(contents) with buffer: audio_array, _= librosa.load(buffer, sr=16000) text = pipe(audio_array)["text"] return {"text": text}