Spaces:
Runtime error
Runtime error
import streamlit as st | |
import openai | |
# Access the OpenAI API key from Hugging Face Spaces secrets | |
openai.api_key = st.secrets["OPENAI_API_KEY"] | |
st.title("Small Business Video Scripter") | |
# User inputs | |
st.subheader("About Your Business") | |
business_description = st.text_area("Describe Your Business", placeholder="What does your business do? What are its unique features?") | |
target_audience = st.text_area("Target Audience", placeholder="Describe the kinds of people you want to attract (e.g., demographics, interests)") | |
st.subheader("Video Type and Platform") | |
video_type = st.text_input("Video Type/Platform", placeholder="E.g., TikTok, Instagram Reels, YouTube") | |
st.subheader("Initial Video Ideas") | |
initial_ideas = st.text_area("Initial Video Ideas", placeholder="Any initial ideas or themes you have in mind for the video?") | |
if st.button('Generate Video Script'): | |
# Detailed prompt for AI including the steps | |
ai_instructions = """ | |
As an AI consultant, create a video script suitable for the specified platform and format, focusing on engaging content that resonates with the business's target audience. | |
Steps: | |
1. Review the business description, target audience, and initial video ideas to brainstorm 20 potential video concepts with compelling hooks. | |
2. Select the best concept and develop a script. The script should be under 200 words, aligning with effective short-form video formats. | |
3. Include a strong call to action relevant to the small business. | |
4. Provide the script first, followed by additional filming and editing tips suitable for the chosen platform. | |
The script should be teleprompter-ready, free of shot directions or speaker references. | |
""" | |
# Construct the prompt for the AI | |
prompt_text = f"{ai_instructions}\nBusiness description: {business_description}. Target audience: {target_audience}. Video type/platform: {video_type}. Initial video ideas: {initial_ideas}." | |
# Call the OpenAI API for text generation | |
try: | |
response_text = openai.ChatCompletion.create( | |
model="gpt-4", | |
messages=[ | |
{"role": "system", "content": ai_instructions}, | |
{"role": "user", "content": prompt_text} | |
] | |
) | |
script = response_text.choices[0].message['content'] | |
except Exception as e: | |
script = f"Error in generating video script: {e}" | |
# Display the video script | |
st.markdown("### Your Video Script") | |
st.write(script) | |
# Disclaimer | |
st.write("Disclaimer: This script is AI-generated. Please review and customize it to fit your specific business needs and video platform.") | |