factorstudios commited on
Commit
55c9b3c
·
verified ·
1 Parent(s): 9c222d9

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +10 -7
server.py CHANGED
@@ -81,7 +81,7 @@ def extract_segments_from_response(response_text: str) -> List[Dict]:
81
  "segment_number": item.get("segment_number", len(segments) + 1),
82
  "title": item.get("title", f"Segment {len(segments) + 1}"),
83
  "start_time": parse_segment_timestamp(item.get("start_time", "00:00:00")),
84
- "end_time": parse_segment_timestamp(item.get("end_time", "00:01:00")),
85
  "description": item.get("description", ""),
86
  "engagement_level": item.get("engagement_level", "high"),
87
  "reason": item.get("reason", "")
@@ -108,7 +108,7 @@ def extract_segments_from_response(response_text: str) -> List[Dict]:
108
  end_time = f"{int(time_match.group(4)):02d}:{time_match.group(5)}:{time_match.group(6)}"
109
  else:
110
  start_time = "00:00:00"
111
- end_time = "00:01:00"
112
 
113
  # Extract first sentence as title
114
  title_match = re.match(r'([^.\n]+)', part.strip())
@@ -152,21 +152,24 @@ async def process_transcription_for_highlights(
152
  system_prompt = """You are a movie marketing expert who identifies the most engaging and thrilling segments of movies.
153
  You will receive a full movie transcript with timestamps. Your task is to identify exactly 10 of the most compelling moments that would make audiences want to watch the full movie.
154
 
155
- IMPORTANT: You MUST respond with a valid JSON array. Do not include any text before or after the JSON array.
 
 
 
156
 
157
  Each segment must have:
158
  - segment_number: (1-10)
159
  - title: (engaging, compelling title for this moment)
160
  - start_time: (HH:MM:SS format - when this segment starts)
161
- - end_time: (HH:MM:SS format - when this segment ends)
162
  - description: (brief description of why this is engaging)
163
  - engagement_level: (high/medium)
164
  - reason: (one-line reason this will hook viewers)
165
 
166
  Return ONLY the JSON array. Example format:
167
  [
168
- {"segment_number": 1, "title": "Epic Action Scene", "start_time": "00:15:32", "end_time": "00:18:45", "description": "...", "engagement_level": "high", "reason": "..."},
169
- {"segment_number": 2, "title": "Emotional Climax", "start_time": "00:45:12", "end_time": "00:48:30", "description": "...", "engagement_level": "high", "reason": "..."}
170
  ]
171
  """
172
 
@@ -366,4 +369,4 @@ async def get_status():
366
  if __name__ == "__main__":
367
  print("Starting Movie Highlight Extraction Service on port 7861...")
368
  print("Will automatically scan and process transcriptions on startup")
369
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
81
  "segment_number": item.get("segment_number", len(segments) + 1),
82
  "title": item.get("title", f"Segment {len(segments) + 1}"),
83
  "start_time": parse_segment_timestamp(item.get("start_time", "00:00:00")),
84
+ "end_time": parse_segment_timestamp(item.get("end_time", "00:10:00")), # 10 minutes
85
  "description": item.get("description", ""),
86
  "engagement_level": item.get("engagement_level", "high"),
87
  "reason": item.get("reason", "")
 
108
  end_time = f"{int(time_match.group(4)):02d}:{time_match.group(5)}:{time_match.group(6)}"
109
  else:
110
  start_time = "00:00:00"
111
+ end_time = "00:10:00" # 10 minutes default
112
 
113
  # Extract first sentence as title
114
  title_match = re.match(r'([^.\n]+)', part.strip())
 
152
  system_prompt = """You are a movie marketing expert who identifies the most engaging and thrilling segments of movies.
153
  You will receive a full movie transcript with timestamps. Your task is to identify exactly 10 of the most compelling moments that would make audiences want to watch the full movie.
154
 
155
+ IMPORTANT:
156
+ - You MUST respond with a valid JSON array ONLY. Do not include any text before or after the JSON array.
157
+ - Each segment should be approximately 10 MINUTES LONG (600 seconds)
158
+ - End time = Start time + ~10 minutes
159
 
160
  Each segment must have:
161
  - segment_number: (1-10)
162
  - title: (engaging, compelling title for this moment)
163
  - start_time: (HH:MM:SS format - when this segment starts)
164
+ - end_time: (HH:MM:SS format - when this segment ends, approximately 10 minutes after start)
165
  - description: (brief description of why this is engaging)
166
  - engagement_level: (high/medium)
167
  - reason: (one-line reason this will hook viewers)
168
 
169
  Return ONLY the JSON array. Example format:
170
  [
171
+ {"segment_number": 1, "title": "Epic Action Scene", "start_time": "00:15:30", "end_time": "00:25:30", "description": "...", "engagement_level": "high", "reason": "..."},
172
+ {"segment_number": 2, "title": "Emotional Climax", "start_time": "00:45:12", "end_time": "00:55:12", "description": "...", "engagement_level": "high", "reason": "..."}
173
  ]
174
  """
175
 
 
369
  if __name__ == "__main__":
370
  print("Starting Movie Highlight Extraction Service on port 7861...")
371
  print("Will automatically scan and process transcriptions on startup")
372
+ uvicorn.run(app, host="0.0.0.0", port=7861)