Spaces:
Sleeping
Sleeping
Update app.py
Browse filessolved a text error
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
|
| 71 |
-
#
|
|
|
|
|
|
|
|
|
|
| 72 |
glow_clip = TextClip(
|
| 73 |
text=word_text,
|
| 74 |
font_size=font_size,
|
| 75 |
color=font_color,
|
| 76 |
-
stroke_color=font_color,
|
| 77 |
-
stroke_width=stroke_width +
|
| 78 |
method='caption',
|
| 79 |
size=(int(final_video_clip.w * 0.9), None)
|
| 80 |
-
).
|
| 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 |
-
).
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
#
|
| 94 |
-
|
|
|
|
| 95 |
|
| 96 |
-
subtitle_clips.append(
|
| 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)...")
|