init
This commit is contained in:
19
app/main.py
Normal file
19
app/main.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from fastapi import FastAPI, File, UploadFile
|
||||
import os
|
||||
import shutil
|
||||
from whispercpp import Whisper
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
model_path = "./app/model/ggml-base.en.bin"
|
||||
whisper = Whisper(model_path)
|
||||
|
||||
@app.post("/transcribe")
|
||||
async def transcribe_audio(audio: UploadFile = File(...)):
|
||||
temp_file = f"temp_{audio.filename}"
|
||||
with open(temp_file, "wb") as buffer:
|
||||
shutil.copyfileobj(audio.file, buffer)
|
||||
|
||||
text = whisper.transcribe(temp_file)
|
||||
os.remove(temp_file)
|
||||
return {"text": text}
|
||||
Reference in New Issue
Block a user