factorstudios commited on
Commit
d01b941
·
verified ·
1 Parent(s): 99a0700

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +7 -2
server.py CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env python3
2
  import os
3
  import json
4
  import asyncio
@@ -125,9 +125,14 @@ def process_video_sync(video_path, output_path, start_t, end_t):
125
  subprocess.run(["ffmpeg", "-y", "-ss", str(start_s), "-to", str(end_s), "-i", video_path, "-c", "copy", temp_seg], capture_output=True)
126
  subprocess.run(["ffmpeg", "-y", "-i", temp_seg, "-vn", "-acodec", "pcm_s16le", "-ar", "16000", "-ac", "1", temp_wav], capture_output=True)
127
  captions = []
128
- if whisper_model:
 
 
129
  segs, _ = whisper_model.transcribe(temp_wav)
130
  captions = [(s.start, s.end, s.text.strip()) for s in segs if s.text.strip()]
 
 
 
131
  cap = cv2.VideoCapture(temp_seg)
132
  fps = cap.get(cv2.CAP_PROP_FPS) or 24
133
  width, height = 1080, 1350
 
1
+ #!/usr/bin/env python3
2
  import os
3
  import json
4
  import asyncio
 
125
  subprocess.run(["ffmpeg", "-y", "-ss", str(start_s), "-to", str(end_s), "-i", video_path, "-c", "copy", temp_seg], capture_output=True)
126
  subprocess.run(["ffmpeg", "-y", "-i", temp_seg, "-vn", "-acodec", "pcm_s16le", "-ar", "16000", "-ac", "1", temp_wav], capture_output=True)
127
  captions = []
128
+ add_log(f"[process_video_sync] Whisper model ready: {processing_state["whisper_ready"]}")
129
+ add_log(f"[process_video_sync] Whisper model instance: {whisper_model is not None}")
130
+ if whisper_model and processing_state["whisper_ready"]:
131
  segs, _ = whisper_model.transcribe(temp_wav)
132
  captions = [(s.start, s.end, s.text.strip()) for s in segs if s.text.strip()]
133
+ add_log(f"[process_video_sync] Transcribed {len(captions)} captions for {temp_wav}")
134
+ if not captions:
135
+ add_log("[process_video_sync] WARNING: No captions transcribed. Check audio or model.")
136
  cap = cv2.VideoCapture(temp_seg)
137
  fps = cap.get(cv2.CAP_PROP_FPS) or 24
138
  width, height = 1080, 1350