|
|
import uvicorn |
|
|
from fastapi import FastAPI, File, UploadFile |
|
|
from func import detect_language_local, transcribe_and_diarize_audio |
|
|
|
|
|
app = FastAPI(docs_url="/") |
|
|
|
|
|
|
|
|
@app.post("/transcribe/") |
|
|
async def transcribe(file: UploadFile = File(...)): |
|
|
|
|
|
file_location = f"temp_{file.filename}" |
|
|
|
|
|
|
|
|
with open(file_location, "wb") as f: |
|
|
f.write(await file.read()) |
|
|
|
|
|
|
|
|
language = detect_language_local(file_location) |
|
|
|
|
|
|
|
|
text, diarized = transcribe_and_diarize_audio(filename=file_location, language=language) |
|
|
|
|
|
return {"diarized": diarized} |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
uvicorn.run(app, host="0.0.0.0", port=8000) |
|
|
|