# =========================== # Ultimate AI App - Final CPU Only (Zero Interaction) # =========================== # Required Libraries: # pip install diffusers transformers torch TTS moviepy pillow import torch from diffusers import StableDiffusionPipeline from TTS.api import TTS from transformers import pipeline from moviepy.editor import ImageSequenceClip import numpy as np from PIL import Image # =========================== # DEFAULT PROMPTS # =========================== DEFAULT_IMAGE_PROMPT = "3D, 4k, cinematic landscape, highly detailed" DEFAULT_VOICE_TEXT = "Hello! This is a fully automatic AI generation test." DEFAULT_TEXT_PROMPT = "Once upon a time in a futuristic world, AI created wonders." DEFAULT_VIDEO_PROMPT = "Fantasy landscape, cinematic, 512x512" # =========================== # IMAGE GENERATION # =========================== def generate_image(prompt, save_path="generated_image.png"): print("Generating image...") pipe = StableDiffusionPipeline.from_pretrained( "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16 ) # Force CPU pipe = pipe.to("cpu") image = pipe(prompt).images[0] image.save(save_path) print(f"āœ… Image saved as {save_path}") # =========================== # VOICE GENERATION # =========================== def generate_voice(text, save_path="generated_voice.wav"): print("Generating voice...") tts = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=True, gpu=False) tts.tts_to_file(text=text, file_path=save_path) print(f"āœ… Voice saved as {save_path}") # =========================== # TEXT GENERATION # =========================== def generate_text(prompt, max_length=100): print("Generating text...") generator = pipeline('text-generation', model='gpt2', device=-1) # device=-1 ensures CPU result = generator(prompt, max_length=max_length, num_return_sequences=1) with open("generated_text.txt", "w", encoding="utf-8") as f: f.write(result[0]['generated_text']) print(f"āœ… Text saved as generated_text.txt") # =========================== # VIDEO GENERATION (CPU-Friendly) # =========================== def generate_video(prompt, num_frames=5, save_path="generated_video.mp4"): print("Generating video frames on CPU...") pipe = StableDiffusionPipeline.from_pretrained( "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16 ) pipe = pipe.to("cpu") # Force CPU frames = [] for i in range(num_frames): image = pipe(prompt).images[0] frames.append(image.convert("RGB")) clip = ImageSequenceClip([np.array(frame) for frame in frames], fps=2) clip.write_videofile(save_path) print(f"āœ… Video saved as {save_path}") # =========================== # MAIN - ZERO INTERACTION # =========================== if __name__ == "__main__": print("=== Ultimate AI App - Final CPU Only ===\n") generate_image(DEFAULT_IMAGE_PROMPT) generate_voice(DEFAULT_VOICE_TEXT) generate_text(DEFAULT_TEXT_PROMPT) generate_video(DEFAULT_VIDEO_PROMPT) print("\nšŸŽ‰ All tasks completed! All files are saved in this folder.")