transcrip / app.py
zerk1's picture
Update app.py
5649b92 verified
raw
history blame contribute delete
920 Bytes
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)