|
|
|
|
|
|
|
from fastapi import FastAPI, UploadFile |
|
from fastapi.staticfiles import StaticFiles |
|
from fastapi.responses import FileResponse |
|
|
|
|
|
from transformers import pipeline |
|
|
|
|
|
|
|
app = FastAPI() |
|
|
|
|
|
|
|
deepneurones= pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h") |
|
|
|
@app.get("/healthcheck") |
|
def healthcheck(): |
|
|
|
|
|
|
|
|
|
return {"output":"OK"} |
|
@app.get("/stt") |
|
async def stt(file: str = UploadFile(...)): |
|
file_content = base64.b64decode(file) |
|
contents = await file.read() |
|
dataset = load_dataset("PolyAI/minds14", name="en-US", split="train") |
|
results = deepneurones(file_content) |
|
return {"output":results} |
|
|
|
|
|
|
|
@app.get("/") |
|
def index() -> FileResponse: |
|
return FileResponse(path="/home/user/app/index.html", media_type="text/html") |
|
|
|
|
|
|
|
|
|
|