a6gitti commited on
Commit
9916ea1
·
verified ·
1 Parent(s): 8e8a314

Update app.py

Browse files

solved a text error

Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -67,19 +67,21 @@ async def generate_video(text, video_path, voice, voice_speed, font_size, font_c
67
  for word_info in segment.get('words', []):
68
  word_text = word_info['word'].strip().upper()
69
 
70
- # New "Neon Glow" Style (using double strokes)
71
- # First layer: The glow (thick stroke)
 
 
 
72
  glow_clip = TextClip(
73
  text=word_text,
74
  font_size=font_size,
75
  color=font_color,
76
- stroke_color=font_color, # Match font color for glow effect
77
- stroke_width=stroke_width + 5,
78
  method='caption',
79
  size=(int(final_video_clip.w * 0.9), None)
80
- ).with_start(word_info['start']).with_duration(word_info['end'] - word_info['start']).with_position(('center', int(final_video_clip.h * 0.65))).with_opacity(0.4)
81
 
82
- # Second layer: The main text
83
  txt_clip = TextClip(
84
  text=word_text,
85
  font_size=font_size,
@@ -88,12 +90,16 @@ async def generate_video(text, video_path, voice, voice_speed, font_size, font_c
88
  stroke_width=stroke_width,
89
  method='caption',
90
  size=(int(final_video_clip.w * 0.9), None)
91
- ).with_start(word_info['start']).with_duration(word_info['end'] - word_info['start']).with_position(('center', int(final_video_clip.h * 0.65)))
 
 
 
92
 
93
- # Group them so they animate together
94
- combined_word = CompositeVideoClip([glow_clip, txt_clip], size=final_video_clip.size).with_start(word_info['start']).with_duration(word_info['end'] - word_info['start'])
 
95
 
96
- subtitle_clips.append(apply_tiktok_animation(combined_word))
97
 
98
  # 4. Export
99
  progress(0.8, desc="🚀 Rendering final video (Exporting)...")
 
67
  for word_info in segment.get('words', []):
68
  word_text = word_info['word'].strip().upper()
69
 
70
+ # New "Neon Glow" Style
71
+ # We set these to start at 0 internally so the container handles the real timing
72
+ duration = word_info['end'] - word_info['start']
73
+ if duration <= 0: duration = 0.1
74
+
75
  glow_clip = TextClip(
76
  text=word_text,
77
  font_size=font_size,
78
  color=font_color,
79
+ stroke_color=font_color,
80
+ stroke_width=stroke_width + 6,
81
  method='caption',
82
  size=(int(final_video_clip.w * 0.9), None)
83
+ ).with_duration(duration).with_position('center').with_opacity(0.4)
84
 
 
85
  txt_clip = TextClip(
86
  text=word_text,
87
  font_size=font_size,
 
90
  stroke_width=stroke_width,
91
  method='caption',
92
  size=(int(final_video_clip.w * 0.9), None)
93
+ ).with_duration(duration).with_position('center')
94
+
95
+ # Combine layers into one "word unit" starting at 0 internally
96
+ word_unit = CompositeVideoClip([glow_clip, txt_clip], size=txt_clip.size, bg_color=None).with_duration(duration)
97
 
98
+ # Now apply the animation and the REAL start time to the whole unit
99
+ word_unit = apply_tiktok_animation(word_unit)
100
+ word_unit = word_unit.with_start(word_info['start']).with_position(('center', int(final_video_clip.h * 0.65)))
101
 
102
+ subtitle_clips.append(word_unit)
103
 
104
  # 4. Export
105
  progress(0.8, desc="🚀 Rendering final video (Exporting)...")