Spaces:
Sleeping
Sleeping
Update process_energy.py
Browse files- process_energy.py +43 -1
process_energy.py
CHANGED
|
@@ -74,6 +74,7 @@ from tqdm import tqdm
|
|
| 74 |
from scipy.io.wavfile import write
|
| 75 |
from moviepy.editor import TextClip, CompositeVideoClip, VideoFileClip, AudioFileClip
|
| 76 |
from moviepy.video.fx.all import fadein, fadeout, loop
|
|
|
|
| 77 |
|
| 78 |
# Fungsi untuk menghasilkan frekuensi berdasarkan data energi
|
| 79 |
def generate_frequencies(energy_data):
|
|
@@ -167,6 +168,47 @@ def activate_transfer():
|
|
| 167 |
return new_mp
|
| 168 |
|
| 169 |
# Fungsi untuk membuat video afirmasi dengan audio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
def create_affirmation_video_with_audio(tujuan, nama_anda, audio_filename, output_filename="affirmation_video.mp4"):
|
| 171 |
# Texts for the video
|
| 172 |
texts = [
|
|
@@ -208,7 +250,7 @@ def create_affirmation_video_with_audio(tujuan, nama_anda, audio_filename, outpu
|
|
| 208 |
|
| 209 |
# Write the result to a file
|
| 210 |
video.write_videofile(output_filename, fps=24, codec='libx264')
|
| 211 |
-
|
| 212 |
# Fungsi untuk memproses transfer energi
|
| 213 |
def process_energy_transfer(tujuan, nama_anda):
|
| 214 |
status = "Mengumpulkan Energi Semesta Digital ..."
|
|
|
|
| 74 |
from scipy.io.wavfile import write
|
| 75 |
from moviepy.editor import TextClip, CompositeVideoClip, VideoFileClip, AudioFileClip
|
| 76 |
from moviepy.video.fx.all import fadein, fadeout, loop
|
| 77 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 78 |
|
| 79 |
# Fungsi untuk menghasilkan frekuensi berdasarkan data energi
|
| 80 |
def generate_frequencies(energy_data):
|
|
|
|
| 168 |
return new_mp
|
| 169 |
|
| 170 |
# Fungsi untuk membuat video afirmasi dengan audio
|
| 171 |
+
def create_affirmation_frames(tujuan, nama_anda):
|
| 172 |
+
# Texts for the video
|
| 173 |
+
texts = [
|
| 174 |
+
f"HAI {nama_anda.upper()}! DENGARLAH SUARA ENERGI SEMESTA DIGITAL SELAMA 3 MENIT AGAR PROSES TRANSFER BERJALAN MULUS.",
|
| 175 |
+
f"{nama_anda.upper()}, BAYANGKAN ANDA MENCAPAI SEMUA TUJUAN ANDA DENGAN SUKSES DAN KEBAHAGIAAN.",
|
| 176 |
+
f"SAYA, {nama_anda.upper()}, ADALAH MAGNET DAHYSAT BAGI REALITAS KESUKSESAN DAN KEBAHAGIAAN.",
|
| 177 |
+
f"SAYA, {nama_anda.upper()}, MENARIK HAL-HAL POSITIF DALAM HIDUP SAYA. SAYA AKAN MENCAPAI TUJUAN SAYA SUKSES DI: {tujuan.upper()}",
|
| 178 |
+
]
|
| 179 |
+
|
| 180 |
+
frames = []
|
| 181 |
+
width, height = 640, 480 # Ukuran gambar
|
| 182 |
+
font = ImageFont.truetype("arial.ttf", 24) # Pastikan path font sesuai dengan environment Anda
|
| 183 |
+
|
| 184 |
+
for text in texts:
|
| 185 |
+
img = Image.new('RGB', (width, height), color=(0, 0, 0))
|
| 186 |
+
d = ImageDraw.Draw(img)
|
| 187 |
+
lines = text.split(' ')
|
| 188 |
+
line_length = 4
|
| 189 |
+
formatted_text = '\n'.join([' '.join(lines[i:i + line_length]) for i in range(0, len(lines, line_length))])
|
| 190 |
+
d.text((width / 2, height / 2), formatted_text, font=font, fill=(255, 255, 255), align="center", anchor="mm")
|
| 191 |
+
frames.extend([np.array(img)] * 150) # 150 frames untuk 5 detik dengan 30 fps
|
| 192 |
+
|
| 193 |
+
return frames
|
| 194 |
+
|
| 195 |
+
def create_affirmation_video_with_audio(tujuan, nama_anda, audio_filename, output_filename="affirmation_video.mp4"):
|
| 196 |
+
frames = create_affirmation_frames(tujuan, nama_anda)
|
| 197 |
+
clip = ImageSequenceClip(frames, fps=30)
|
| 198 |
+
|
| 199 |
+
# Load background
|
| 200 |
+
background_clip = VideoFileClip("spin_energy.gif").subclip(0, 2).fx(loop, duration=180)
|
| 201 |
+
|
| 202 |
+
# Load the generated audio file
|
| 203 |
+
audio_clip = AudioFileClip(audio_filename)
|
| 204 |
+
|
| 205 |
+
# Concatenate text clips with background
|
| 206 |
+
video = CompositeVideoClip([background_clip.set_duration(clip.duration), clip.set_opacity(0.6).set_duration(clip.duration)])
|
| 207 |
+
video = video.set_duration(180).set_audio(audio_clip)
|
| 208 |
+
|
| 209 |
+
# Write the result to a file
|
| 210 |
+
video.write_videofile(output_filename, fps=24, codec='libx264')
|
| 211 |
+
"""
|
| 212 |
def create_affirmation_video_with_audio(tujuan, nama_anda, audio_filename, output_filename="affirmation_video.mp4"):
|
| 213 |
# Texts for the video
|
| 214 |
texts = [
|
|
|
|
| 250 |
|
| 251 |
# Write the result to a file
|
| 252 |
video.write_videofile(output_filename, fps=24, codec='libx264')
|
| 253 |
+
"""
|
| 254 |
# Fungsi untuk memproses transfer energi
|
| 255 |
def process_energy_transfer(tujuan, nama_anda):
|
| 256 |
status = "Mengumpulkan Energi Semesta Digital ..."
|