bigbossmonster commited on
Commit
3f352e8
·
verified ·
1 Parent(s): b06c0aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -115,41 +115,41 @@ async def stream_generator(file_path: str, display_name: str, api_key: str, mode
115
 
116
  yield log_msg(f"Ready. Starting generation for full duration...")
117
 
118
- # 4. Prompt Construction (Reverted to Stable Version)
119
  end_time_instruction = total_duration_str if total_duration_str != "Unknown" else "the absolute end of the file"
120
 
121
  instruction_set = f"""
122
- 1. Transcribe audio from 00:00:00 to {end_time_instruction}.
123
  2. Translate to natural Burmese (Myanmar).
124
- 3. Output format: Standard SRT.
 
 
 
 
125
  """
126
 
127
  if include_songs:
128
- instruction_set += "\n 4. For SONGS: Use 🎶."
129
  else:
130
  instruction_set += "\n 4. Ignore background music/lyrics."
131
 
132
  if include_on_screen_text:
133
- instruction_set += "\n 5. For ON-SCREEN TEXT: Use 📝."
134
  else:
135
  instruction_set += "\n 5. Ignore visual text."
136
 
137
- # Stability Instructions
138
  instruction_set += f"""
139
- 6. **SYNC CRITICAL**:
140
- - The file duration is EXACTLY {end_time_instruction}.
141
- - Do NOT stop early. If there is silence, wait for the next dialogue.
142
- - Only write "End" when the timestamp reaches {end_time_instruction}.
143
-
144
- 7. **TIMESTAMP CORRECTION**:
145
- - Start time must be 00:00:00.
146
- - **DO NOT** write "01:00:00" (1 hour) unless the video is actually longer than 60 minutes.
147
- - e.g., Use "00:01:10", NOT "01:01:10".
148
  """
149
 
150
  prompt = f"""
151
- Task: Create Burmese SRT subtitles for the ENTIRE duration.
152
- TOTAL DURATION: {total_duration_str}
153
  INSTRUCTIONS:{instruction_set}
154
  """
155
 
@@ -161,7 +161,7 @@ async def stream_generator(file_path: str, display_name: str, api_key: str, mode
161
  response_stream = model.generate_content(
162
  [video_file, prompt],
163
  stream=True,
164
- generation_config={"temperature": 0.2} # Reverted to 0.2 (Stable)
165
  )
166
 
167
  chunk_count = 0
 
115
 
116
  yield log_msg(f"Ready. Starting generation for full duration...")
117
 
118
+ # 4. Prompt Construction (Optimized for Sync)
119
  end_time_instruction = total_duration_str if total_duration_str != "Unknown" else "the absolute end of the file"
120
 
121
  instruction_set = f"""
122
+ 1. Transcribe the audio from 00:00:00 to {end_time_instruction}.
123
  2. Translate to natural Burmese (Myanmar).
124
+ 3. **TIMING RULE**:
125
+ - **Do NOT fill gaps.** If there is music without lyrics, leave it blank.
126
+ - Timestamps must match the **exact start and end** of the singing/speech.
127
+ - Do NOT make timestamps continuous (e.g., if line 1 ends at 00:05 and line 2 starts at 00:10, do NOT extend line 1 to 00:10).
128
+ - Break subtitles when the singer takes a breath.
129
  """
130
 
131
  if include_songs:
132
+ instruction_set += "\n 4. SONGS: Capture lyrics. Use 🎶 at start/end."
133
  else:
134
  instruction_set += "\n 4. Ignore background music/lyrics."
135
 
136
  if include_on_screen_text:
137
+ instruction_set += "\n 5. ON-SCREEN TEXT: Use 📝."
138
  else:
139
  instruction_set += "\n 5. Ignore visual text."
140
 
 
141
  instruction_set += f"""
142
+ 6. **SYNC CHECK**:
143
+ - Start time MUST be 00:00:00.
144
+ - Ensure timestamps do NOT overlap.
145
+ - Continue until {end_time_instruction}.
146
+ - **Timestamp Format**: HH:MM:SS,mmm (e.g. 00:01:23,450)
147
+ - **NO HALLUCINATED HOURS**: Do not write "01:00:00" if video is short.
 
 
 
148
  """
149
 
150
  prompt = f"""
151
+ Task: Create accurate, synced Burmese SRT subtitles.
152
+ Total Duration: {total_duration_str}
153
  INSTRUCTIONS:{instruction_set}
154
  """
155
 
 
161
  response_stream = model.generate_content(
162
  [video_file, prompt],
163
  stream=True,
164
+ generation_config={"temperature": 0.0} # Temperature 0.0 for strictest adherence to timing
165
  )
166
 
167
  chunk_count = 0