Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -117,36 +117,42 @@ def split_sentences(text):
|
|
117 |
def display_script(title, script):
|
118 |
script_sentences = split_sentences(script)
|
119 |
formatted_script = "\n\n".join(script_sentences)
|
120 |
-
return f"#
|
121 |
-
|
122 |
-
|
123 |
-
script_sentences = split_sentences(script)
|
124 |
-
formatted_script = "\n\n".join(script_sentences)
|
125 |
-
return f"""<h2>{title}</h2>
|
126 |
<details>
|
127 |
-
<summary
|
128 |
-
<pre>{formatted_script}</pre>
|
129 |
-
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
def analyze(url):
|
132 |
title, description, script = get_youtube_script(url)
|
133 |
script_content = display_script(title, script)
|
|
|
134 |
summary = summarize_text(title, description, script)
|
135 |
-
summary_content =
|
136 |
-
|
137 |
|
138 |
# Gradio ์ธํฐํ์ด์ค
|
139 |
with gr.Blocks() as demo:
|
140 |
gr.Markdown("## YouTube ์คํฌ๋ฆฝํธ ์ถ์ถ ๋ฐ ์์ฝ ๋๊ตฌ")
|
141 |
youtube_url_input = gr.Textbox(label="YouTube URL ์
๋ ฅ")
|
142 |
analyze_button = gr.Button("๋ถ์ํ๊ธฐ")
|
143 |
-
script_output = gr.HTML(label="์๋ฌธ ์คํฌ๋ฆฝํธ")
|
144 |
-
summary_output = gr.HTML(label="์์ฝ")
|
145 |
|
146 |
analyze_button.click(
|
147 |
analyze,
|
148 |
inputs=[youtube_url_input],
|
149 |
-
outputs=[script_output, summary_output]
|
150 |
)
|
151 |
|
152 |
if __name__ == "__main__":
|
|
|
117 |
def display_script(title, script):
|
118 |
script_sentences = split_sentences(script)
|
119 |
formatted_script = "\n\n".join(script_sentences)
|
120 |
+
return f"""<div style="background-color: #f0f0f0; padding: 20px; border-radius: 10px;">
|
121 |
+
<h3>์๋ฌธ ์คํฌ๋ฆฝํธ</h3>
|
122 |
+
<h2>{title}</h2>
|
|
|
|
|
|
|
123 |
<details>
|
124 |
+
<summary>ํด๋ฆญํ์ฌ ํผ์น๊ธฐ</summary>
|
125 |
+
<pre style="white-space: pre-wrap;">{formatted_script}</pre>
|
126 |
+
</details>
|
127 |
+
</div>"""
|
128 |
+
|
129 |
+
def display_summary(title, summary):
|
130 |
+
return f"""<div style="background-color: #e6f3ff; padding: 20px; border-radius: 10px; margin-top: 20px;">
|
131 |
+
<h3>์์ฝ</h3>
|
132 |
+
<h2>{title}</h2>
|
133 |
+
{summary}
|
134 |
+
</div>"""
|
135 |
|
136 |
def analyze(url):
|
137 |
title, description, script = get_youtube_script(url)
|
138 |
script_content = display_script(title, script)
|
139 |
+
yield script_content, gr.update(visible=True), gr.update(value="<div style='text-align: center; margin-top: 20px;'>์์ฝ ์์ฑ ์ค...</div>", visible=True)
|
140 |
summary = summarize_text(title, description, script)
|
141 |
+
summary_content = display_summary(title, summary)
|
142 |
+
yield script_content, gr.update(visible=True), gr.update(value=summary_content, visible=True)
|
143 |
|
144 |
# Gradio ์ธํฐํ์ด์ค
|
145 |
with gr.Blocks() as demo:
|
146 |
gr.Markdown("## YouTube ์คํฌ๋ฆฝํธ ์ถ์ถ ๋ฐ ์์ฝ ๋๊ตฌ")
|
147 |
youtube_url_input = gr.Textbox(label="YouTube URL ์
๋ ฅ")
|
148 |
analyze_button = gr.Button("๋ถ์ํ๊ธฐ")
|
149 |
+
script_output = gr.HTML(label="์๋ฌธ ์คํฌ๋ฆฝํธ", visible=False)
|
150 |
+
summary_output = gr.HTML(label="์์ฝ", visible=False)
|
151 |
|
152 |
analyze_button.click(
|
153 |
analyze,
|
154 |
inputs=[youtube_url_input],
|
155 |
+
outputs=[script_output, script_output, summary_output]
|
156 |
)
|
157 |
|
158 |
if __name__ == "__main__":
|