zerk1 commited on
Commit
0225b27
·
verified ·
1 Parent(s): 34f0e5f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uvicorn
2
+ from fastapi import FastAPI, File, UploadFile
3
+ from func import detect_language_local, transcribe_and_diarize_audio
4
+
5
+ app = FastAPI(docs_url="/")
6
+
7
+
8
+ @app.post("/transcribe/")
9
+ async def transcribe(file: UploadFile = File(...)):
10
+ # Сохраняем загруженный файл временно
11
+ file_location = f"temp_{file.filename}"
12
+
13
+ # Читаем содержимое файла и записываем его на диск
14
+ with open(file_location, "wb") as f:
15
+ f.write(await file.read())
16
+
17
+ # Детектируем язык
18
+ language = detect_language_local(file_location)
19
+
20
+ # Обрабатываем файл (транскрипция и сегментация)
21
+ text, diarized = transcribe_and_diarize_audio(filename=file_location, language=language)
22
+
23
+ return {"diarized": diarized}
24
+
25
+