Art_Generator / app.py
Saanvi12011's picture
Create app.py
5edce69 verified
raw
history blame contribute delete
823 Bytes
import streamlit as st
from transformers import pipeline
# Initialize text generation pipeline
text_generator = pipeline("text-generation", model="gpt2")
st.title("Poetry or Song Lyrics Generator")
st.write("Generate creative poetry or lyrics based on a theme.")
theme = st.text_input("Enter a theme or starting phrase:", placeholder="E.g., Love, Nature, Dreams...")
word_count = st.slider("Select maximum words:", 50, 200, 100)
if st.button("Generate"):
if not theme.strip():
st.error("Please provide a theme or starting phrase.")
else:
with st.spinner("Generating creative text..."):
generated_text = text_generator(theme, max_length=word_count, num_return_sequences=1)
st.subheader("Generated Poetry/Lyrics:")
st.write(generated_text[0]["generated_text"])