File size: 3,477 Bytes
d64a66d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86



import streamlit as st
from langchain import PromptTemplate
from langchain.llms import OpenAI
import math


# LLM loading function
def load_LLM(openai_api_key):
    llm = OpenAI(openai_api_key=openai_api_key)
    return llm


# Generate content plan with GPT-3
def generate_content_plan(llm, content_input, video_length, video_style, tone):
    prompt = f"""Generate a {content_type} {video_length}-minute long video content plan based on the article. Prioritize key insights and allocate time to each section based on its complexity, relevance to the overall topic, and fitting within the {video_length} time frame. Specify the time in seconds for each section. The article is as follows: {content_input}
    Make sure to distribute the time effectively among sections to ensure a balanced and informative video within the specified time limit.For sections, ensure that the total duration does not exceed {video_length}. the video is for {video_style} and users are {tone}
    Each section should be described as a JSON-like object: {{ "Title": "section_title", "Description": "description", "Duration": "duration in seconds" }}




    """
    content_plan = llm(prompt)
    return content_plan
# Generate detailed content for each section
def generate_detailed_content(llm, content_input, video_length, video_style, tone, content_type, content_plan):
    prompt = f"""Based on the content plan provided below, create a detailed script for a {video_length}-minute video:
    Content Plan: {content_plan}

    Please note:
    - 'Title' refers to the title of the section.
    - 'Description' refers to a brief overview of the section.
    - 'Duration' refers to the time allocated to each section in seconds.

    The script should include:
    - Introductory lines for each section
    - Key points for each section
    - Data or examples to support key points
    - Transitions between sections
    - A closing statement

    Additional Context:
    - Content Type: {content_type}
    - Video Style: {video_style}
    - Target Audience: {tone}
    - Base Article: {content_input}
    """
    
    detailed_content = llm(prompt)
    return detailed_content



# Streamlit UI
st.set_page_config(page_title="ScriptMaven📜🧠", page_icon=":robot:")
st.header("ScriptMaven 📜🧠: Your Edu-Video Blueprint")


openai_api_key = st.text_input("OpenAI API Key", "Ex: sk-2twmA8tfCb8un4...")
video_style = st.selectbox('Video Style:', ('YouTube', 'Corporate'))
tone = st.selectbox('Tone:', ('For Students', 'Director Level', 'New Employee Level', 'CEO Level', 'For Teens'))
video_length = st.selectbox('Video Length:', ('5', '10m', '15m', '20m', '30m'))
content_type = st.selectbox('Content Type:', ('Case Study', 'Masterclass', 'Documentary', 'How-to Videos', 'Coding', 'Summary', 'Review'))
content_input = st.text_area("Content Input", "Your content...")


# Generate plan button
# ...
# Generate Content Plan Button
if st.button("Generate Plan"):
    llm = load_LLM(openai_api_key=openai_api_key)
    content_plan = generate_content_plan(llm, content_input, video_length, video_style, tone)

    # Display the generated plan
    st.write("Generated Content Plan:")
    st.write(content_plan)

    # Pass the generated content_plan directly into the next prompt
    detailed_content = generate_detailed_content(llm, content_plan, content_input, video_length, video_style, tone, content_type)
    
    st.write("Generated Detailed Scripts:")
    st.write(detailed_content)