hivecorp commited on
Commit
b1b1647
·
verified ·
1 Parent(s): 891da99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -77,15 +77,15 @@ def text_to_video(text, voice, rate, pitch, video_width, video_height, bg_color,
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):
84
  draw.text(int(video_width / 2), (j + 1) * (text_size + 10), line)
85
-
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)
@@ -93,6 +93,7 @@ def text_to_video(text, voice, rate, pitch, video_width, video_height, bg_color,
93
  text_clip = ImageClip(img_path).set_duration(audio_clip.duration).set_audio(audio_clip)
94
  video_clips.append(text_clip)
95
 
 
96
  # 合并所有视频片段
97
  final_video = concatenate_videoclips(video_clips)
98
  final_video_path = os.path.join(tempfile.gettempdir(), "output_video.mp4")
 
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):
84
  draw.text(int(video_width / 2), (j + 1) * (text_size + 10), line)
85
+
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)
 
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)
99
  final_video_path = os.path.join(tempfile.gettempdir(), "output_video.mp4")