Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ app = FastAPI()
|
|
| 11 |
|
| 12 |
# === Core Functions ===
|
| 13 |
|
| 14 |
-
def extract_audio(video_path, audio_path="extracted_audio.wav"):
|
| 15 |
video = VideoFileClip(video_path)
|
| 16 |
video.audio.write_audiofile(audio_path)
|
| 17 |
return audio_path
|
|
@@ -42,14 +42,18 @@ def summarize_text(text):
|
|
| 42 |
return final[0]['summary_text']
|
| 43 |
return full_summary
|
| 44 |
|
| 45 |
-
# === FastAPI
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
@app.post("/process/")
|
| 48 |
async def process_video(file: UploadFile = File(...)):
|
| 49 |
try:
|
| 50 |
-
video_path = f"temp_{file.filename}"
|
| 51 |
with open(video_path, "wb") as f:
|
| 52 |
-
while chunk := await file.read(1024 * 1024): #
|
| 53 |
f.write(chunk)
|
| 54 |
|
| 55 |
extracted_text = video_to_text(video_path)
|
|
|
|
| 11 |
|
| 12 |
# === Core Functions ===
|
| 13 |
|
| 14 |
+
def extract_audio(video_path, audio_path="/tmp/extracted_audio.wav"):
|
| 15 |
video = VideoFileClip(video_path)
|
| 16 |
video.audio.write_audiofile(audio_path)
|
| 17 |
return audio_path
|
|
|
|
| 42 |
return final[0]['summary_text']
|
| 43 |
return full_summary
|
| 44 |
|
| 45 |
+
# === FastAPI Routes ===
|
| 46 |
+
|
| 47 |
+
@app.get("/")
|
| 48 |
+
def health_check():
|
| 49 |
+
return {"status": "running"}
|
| 50 |
|
| 51 |
@app.post("/process/")
|
| 52 |
async def process_video(file: UploadFile = File(...)):
|
| 53 |
try:
|
| 54 |
+
video_path = f"/tmp/temp_{file.filename}"
|
| 55 |
with open(video_path, "wb") as f:
|
| 56 |
+
while chunk := await file.read(1024 * 1024): # Read in chunks (1MB)
|
| 57 |
f.write(chunk)
|
| 58 |
|
| 59 |
extracted_text = video_to_text(video_path)
|