Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,13 +30,14 @@ def load_style_from_docx(filepath):
|
|
| 30 |
except Exception:
|
| 31 |
return ""
|
| 32 |
|
|
|
|
| 33 |
# 🧠 Script generatie met context en stijl
|
| 34 |
-
def generate_script(
|
| 35 |
if not api_key or not title:
|
| 36 |
return "❌ Vul alle verplichte velden in."
|
| 37 |
|
| 38 |
try:
|
| 39 |
-
client = OpenAI(api_key=
|
| 40 |
context = fetch_recent_info(title)
|
| 41 |
|
| 42 |
if not context or len(context.strip()) < 100:
|
|
@@ -147,8 +148,8 @@ with gr.Blocks() as demo:
|
|
| 147 |
gr.Markdown("# 🎨 Script Writer 2.0 – Met woordtelling en Fact-Check")
|
| 148 |
|
| 149 |
with gr.Row():
|
| 150 |
-
|
| 151 |
-
|
| 152 |
|
| 153 |
style_file = gr.File(label="📄 Upload script for style inspiration (.docx)", file_types=[".docx"], type="filepath")
|
| 154 |
output = gr.Textbox(label="✅ Final Script (Fact-Checked)", lines=30, interactive=False)
|
|
@@ -157,7 +158,7 @@ with gr.Blocks() as demo:
|
|
| 157 |
clear_btn = gr.Button("🪜 Clear")
|
| 158 |
submit_btn = gr.Button("🚀 Genereer")
|
| 159 |
|
| 160 |
-
submit_btn.click(fn=generate_script, inputs=[
|
| 161 |
clear_btn.click(fn=lambda: "", inputs=None, outputs=output)
|
| 162 |
|
| 163 |
# Run app
|
|
|
|
| 30 |
except Exception:
|
| 31 |
return ""
|
| 32 |
|
| 33 |
+
openai_api_key = "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"
|
| 34 |
# 🧠 Script generatie met context en stijl
|
| 35 |
+
def generate_script(title, style_file):
|
| 36 |
if not api_key or not title:
|
| 37 |
return "❌ Vul alle verplichte velden in."
|
| 38 |
|
| 39 |
try:
|
| 40 |
+
client = OpenAI(api_key=openai_api_key)
|
| 41 |
context = fetch_recent_info(title)
|
| 42 |
|
| 43 |
if not context or len(context.strip()) < 100:
|
|
|
|
| 148 |
gr.Markdown("# 🎨 Script Writer 2.0 – Met woordtelling en Fact-Check")
|
| 149 |
|
| 150 |
with gr.Row():
|
| 151 |
+
title = gr.Textbox(label="🎯 Video Title (script topic)")
|
| 152 |
+
|
| 153 |
|
| 154 |
style_file = gr.File(label="📄 Upload script for style inspiration (.docx)", file_types=[".docx"], type="filepath")
|
| 155 |
output = gr.Textbox(label="✅ Final Script (Fact-Checked)", lines=30, interactive=False)
|
|
|
|
| 158 |
clear_btn = gr.Button("🪜 Clear")
|
| 159 |
submit_btn = gr.Button("🚀 Genereer")
|
| 160 |
|
| 161 |
+
submit_btn.click(fn=generate_script, inputs=[title, style_file], outputs=output)
|
| 162 |
clear_btn.click(fn=lambda: "", inputs=None, outputs=output)
|
| 163 |
|
| 164 |
# Run app
|