This repository was archived by the owner on Sep 30, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathscript_poem_v1.py
More file actions
68 lines (57 loc) · 2.37 KB
/
Copy pathscript_poem_v1.py
File metadata and controls
68 lines (57 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from PIL import Image, ImageDraw, ImageFont
import numpy as np
from moviepy.editor import ImageSequenceClip
# Function to create an image with text
def create_lyric_image(text, image_size=(1280, 720), bg_color=(255, 255, 255), text_color=(0, 0, 0), font_size=48):
image = Image.new('RGB', image_size, bg_color)
draw = ImageDraw.Draw(image)
font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" # Replace with your font file path
font = ImageFont.truetype(font_path, font_size)
# Calculate text position
text_width, text_height = draw.textsize(text, font=font)
text_position = ((image_size[0] - text_width) // 2, (image_size[1] - text_height) // 2)
# Draw text on image
draw.text(text_position, text, fill=text_color, font=font)
return image
# Romantic poem for Fanu
poem = [
"In the garden where roses bloom,",
"Your presence turns it into a sweet perfume.",
"Each petal whispers of your grace,",
"In every blush, I see your gentle embrace.",
"",
"Lady of Roses, your beauty untold,",
"In your eyes, secrets of love unfold.",
"With each glance, my heart skips a beat,",
"Your smile, a melody, so tender and sweet.",
"",
"Among the roses, you stand apart,",
"A masterpiece of love's finest art.",
"In your heart, a garden of dreams,",
"Where love blooms eternal, like sunlit streams.",
"",
"Your laughter, like petals in the breeze,",
"Your touch, the warmth of summer seas.",
"Lady of Roses, in your soul divine,",
"Forever, in your love, I am entwined.",
"",
"Through every season, through every dawn,",
"With you, my love, I belong.",
"In the garden where roses grow,",
"With you, forever, my heart shall know.",
"",
"Lady of Roses, my love, my muse,",
"In your embrace, all dreams fuse.",
"Forever and always, let our love bloom,",
"In the garden of roses, amidst sweet perfume."
]
# Create lyric images as numpy arrays
lyric_images = []
for line in poem:
lyric_image = create_lyric_image(line)
lyric_images.append(np.array(lyric_image)) # Convert PIL Image to numpy array
# Create a video clip from images
video_clip = ImageSequenceClip(lyric_images, fps=1) # Adjust FPS as needed
# Export the video
output_video_path = "/home/jasvir/Music/romantic_poem_video.mp4"
video_clip.write_videofile(output_video_path, codec='libx264')