Commit
·
4a0b504
1
Parent(s):
1888874
make srt input of type UploadFile
Browse files
main.py
CHANGED
@@ -10,22 +10,11 @@ from fastapi.responses import HTMLResponse, Response
|
|
10 |
from fastapi.security import HTTPBasic
|
11 |
from pydantic import BaseModel, field_validator
|
12 |
|
|
|
|
|
13 |
app = FastAPI()
|
14 |
security = HTTPBasic()
|
15 |
|
16 |
-
class SRTFile(BaseModel):
|
17 |
-
srt_file: Optional[UploadFile] = None
|
18 |
-
|
19 |
-
@property
|
20 |
-
def size(self):
|
21 |
-
return self.srt_file.size
|
22 |
-
|
23 |
-
@field_validator('srt_file')
|
24 |
-
def validate_srt_file(cls, self):
|
25 |
-
if self.size > 0 and not self.filename.endswith('.srt'):
|
26 |
-
raise HTTPException(status_code=422, detail='Invalid subtitle file type. Please upload an SRT file.')
|
27 |
-
return self
|
28 |
-
|
29 |
@app.get("/")
|
30 |
async def root():
|
31 |
html_content = f"""
|
@@ -50,7 +39,7 @@ async def get_temp_dir():
|
|
50 |
|
51 |
@app.post("/process_video/")
|
52 |
async def process_video_api(video_file: UploadFile = File(media_type="video"),
|
53 |
-
srt_file:
|
54 |
task: Optional[str] = Form("transcribe"),
|
55 |
max_words_per_line: Optional[int] = Form(6),
|
56 |
fontsize: Optional[int] = Form(42),
|
|
|
10 |
from fastapi.security import HTTPBasic
|
11 |
from pydantic import BaseModel, field_validator
|
12 |
|
13 |
+
# TODO: fix sound and resizing issues when video comes from mobile.
|
14 |
+
|
15 |
app = FastAPI()
|
16 |
security = HTTPBasic()
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
@app.get("/")
|
19 |
async def root():
|
20 |
html_content = f"""
|
|
|
39 |
|
40 |
@app.post("/process_video/")
|
41 |
async def process_video_api(video_file: UploadFile = File(media_type="video"),
|
42 |
+
srt_file: UploadFile = File(media_type="text"), #ad validation
|
43 |
task: Optional[str] = Form("transcribe"),
|
44 |
max_words_per_line: Optional[int] = Form(6),
|
45 |
fontsize: Optional[int] = Form(42),
|