Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -119,52 +119,34 @@ def display_script(title, script):
|
|
| 119 |
formatted_script = "\n\n".join(script_sentences)
|
| 120 |
return f"# {title}\n\n{formatted_script}"
|
| 121 |
|
| 122 |
-
def
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
# ์์ฝ ๋ด์ฉ ์ ๋ฆฌ
|
| 138 |
-
summary_content = f"# {title}\n\n{summary}"
|
| 139 |
-
else:
|
| 140 |
-
# ์๋ฃ
|
| 141 |
-
pass
|
| 142 |
-
yield script_content, f"์์ฝ ์์ฑ ์ค... ({i+1}/3)"
|
| 143 |
-
|
| 144 |
-
# ์ต์ข
๊ฒฐ๊ณผ ์ถ๋ ฅ
|
| 145 |
-
yield script_content, summary_content
|
| 146 |
-
except Exception as e:
|
| 147 |
-
error_msg = f"์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
| 148 |
-
logging.exception(error_msg)
|
| 149 |
-
yield error_msg, error_msg
|
| 150 |
|
| 151 |
# Gradio ์ธํฐํ์ด์ค
|
| 152 |
with gr.Blocks() as demo:
|
| 153 |
gr.Markdown("## YouTube ์คํฌ๋ฆฝํธ ์ถ์ถ ๋ฐ ์์ฝ ๋๊ตฌ")
|
| 154 |
youtube_url_input = gr.Textbox(label="YouTube URL ์
๋ ฅ")
|
| 155 |
analyze_button = gr.Button("๋ถ์ํ๊ธฐ")
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
with gr.TabItem("์๋ฌธ ์คํฌ๋ฆฝํธ"):
|
| 159 |
-
script_output = gr.Markdown()
|
| 160 |
-
with gr.TabItem("์์ฝ"):
|
| 161 |
-
summary_output = gr.Markdown()
|
| 162 |
|
| 163 |
analyze_button.click(
|
| 164 |
analyze,
|
| 165 |
inputs=[youtube_url_input],
|
| 166 |
-
outputs=[script_output, summary_output]
|
| 167 |
-
show_progress=True
|
| 168 |
)
|
| 169 |
|
| 170 |
if __name__ == "__main__":
|
|
|
|
| 119 |
formatted_script = "\n\n".join(script_sentences)
|
| 120 |
return f"# {title}\n\n{formatted_script}"
|
| 121 |
|
| 122 |
+
def display_script(title, script):
|
| 123 |
+
script_sentences = split_sentences(script)
|
| 124 |
+
formatted_script = "\n\n".join(script_sentences)
|
| 125 |
+
return f"""<h2>{title}</h2>
|
| 126 |
+
<details>
|
| 127 |
+
<summary>์๋ฌธ ์คํฌ๋ฆฝํธ (ํด๋ฆญํ์ฌ ํผ์น๊ธฐ)</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 = f"<h2>{title}</h2>\n\n{summary}"
|
| 136 |
+
return script_content, summary_content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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__":
|