hivecorp commited on
Commit
06ac653
·
verified ·
1 Parent(s): b1b1647

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -72,12 +72,14 @@ def text_to_video(text, voice, rate, pitch, video_width, video_height, bg_color,
72
 
73
  # 使用 wand 生成视频片段
74
  with Drawing() as draw:
 
75
  draw.font = font_path
76
  draw.font_size = text_size
77
  draw.fill_color = Color(text_color)
78
  draw.text_alignment = 'center'
79
  draw.text_interline_spacing = 10
80
-
 
81
  with Image(width=video_width, height=video_height, background=Color(bg_color)) as img:
82
  lines = page.split("\n")
83
  for j, line in enumerate(lines):
@@ -86,13 +88,14 @@ def text_to_video(text, voice, rate, pitch, video_width, video_height, bg_color,
86
  # Apply the drawing to the image
87
  draw(img)
88
 
 
89
  img.format = 'png'
90
  img_path = os.path.join(tempfile.gettempdir(), f"page_{i}.png")
91
  img.save(filename=img_path)
92
 
 
93
  text_clip = ImageClip(img_path).set_duration(audio_clip.duration).set_audio(audio_clip)
94
  video_clips.append(text_clip)
95
-
96
 
97
  # 合并所有视频片段
98
  final_video = concatenate_videoclips(video_clips)
 
72
 
73
  # 使用 wand 生成视频片段
74
  with Drawing() as draw:
75
+ # Ensure that the following lines are indented correctly
76
  draw.font = font_path
77
  draw.font_size = text_size
78
  draw.fill_color = Color(text_color)
79
  draw.text_alignment = 'center'
80
  draw.text_interline_spacing = 10
81
+
82
+ # Another 'with' block starts here, so make sure this is also properly indented
83
  with Image(width=video_width, height=video_height, background=Color(bg_color)) as img:
84
  lines = page.split("\n")
85
  for j, line in enumerate(lines):
 
88
  # Apply the drawing to the image
89
  draw(img)
90
 
91
+ # Save the image as a PNG file
92
  img.format = 'png'
93
  img_path = os.path.join(tempfile.gettempdir(), f"page_{i}.png")
94
  img.save(filename=img_path)
95
 
96
+ # Create the video clip using the generated image
97
  text_clip = ImageClip(img_path).set_duration(audio_clip.duration).set_audio(audio_clip)
98
  video_clips.append(text_clip)
 
99
 
100
  # 合并所有视频片段
101
  final_video = concatenate_videoclips(video_clips)