Ld75's picture
Update app.py
51d1a4d
raw
history blame
1.53 kB
#import gradio as gr
#gr.Interface.load("models/pyannote/speaker-diarization").launch()
from fastapi import FastAPI, UploadFile
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
#from pyannote.audio import Pipeline
from transformers import pipeline # le framework de huggingface
#from datasets import load_dataset, Audio # ça c'est pour entrainer mon modele
app = FastAPI()
#pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
#deepneurones = pipeline("automatic-speech-recognition")# la liste des pipelines de huggingface est disponible ici :https://huggingface.co/docs/transformers/quicktour. pipeline() telecharge dans un cache local le modele deeplearning
deepneurones= pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h")
@app.get("/healthcheck")
def healthcheck():
#output = pipe_flan(input)
#pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")
#pipeline("file.wav")
return {"output":"OK"}
@app.post("/stt")
async def stt(file: str = UploadFile(...)):
#file_content = base64.b64decode(file)
file_content = await file.read()
#dataset = load_dataset("PolyAI/minds14", name="en-US", split="train")
results = deepneurones(file_content)
return {"output":results}
#app.mount("/", StaticFiles(directory="static", html=True), name="static")
@app.get("/")
def index() -> FileResponse:
return FileResponse(path="/home/user/app/index.html", media_type="text/html")