Spaces:
Sleeping
Sleeping
File size: 857 Bytes
15b9514 55de385 15b9514 55de385 15b9514 55de385 15b9514 55de385 15b9514 55de385 15b9514 55de385 15b9514 55de385 15b9514 |
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 |
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
from transformers import pipeline
# 🎨 Load Stable Diffusion model
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
pipe.to("cpu")
# 🗣️ Load Text-to-Speech model
tts = pipeline("text-to-speech", model="nineninesix/kani-tts-370m")
# Image generation function
def generate_media(prompt):
image = pipe(prompt).images[0]
audio = tts(prompt)
return image, (audio["audio"],)
# Gradio UI
demo = gr.Interface(
fn=generate_media,
inputs=gr.Textbox(label="Enter your prompt"),
outputs=[gr.Image(label="Generated Image"), gr.Audio(label="AI Voice")],
title="AI Image + Voice Generator",
description="Generates an image with a matching AI voiceover using Stable Diffusion XL and KaniTTS"
)
demo.launch()
|