Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -221,6 +221,24 @@ def remove_timeline(script_text, lecture_number):
|
|
| 221 |
cleaned_text = re.sub(r'^WEBVTT\s*', '', cleaned_text)
|
| 222 |
return cleaned_text
|
| 223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
with gr.Blocks() as additional_demo:
|
| 225 |
# ๋ชจ๋2 ์๋จ ์๋ด ๋ฌธ๊ตฌ
|
| 226 |
gr.Markdown("โป ์๋ ์์๋๋ก ๊ฐ ๋จ๊ณ๋ณ ๋ฒํผ์ ๋๋ฌ ์งํํ์ธ์.")
|
|
@@ -311,6 +329,14 @@ with gr.Blocks() as additional_demo:
|
|
| 311 |
gr.Markdown("๋๋ฒ๊น
๋ชจ๋ ํ์ฑํ๋จ: ๋ก๊ทธ๊ฐ ์ฝ์์ ์ถ๋ ฅ๋ฉ๋๋ค.")
|
| 312 |
# ---------- [๋ชจ๋2: ์ถ๊ฐ์ฝ๋] ๋ ----------
|
| 313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
# ---------- ํตํฉ Gradio ์ฑ ๊ตฌ์ฑ (ํ ํ์ด์ง์ ๋ชจ๋ ํ์) ----------
|
| 315 |
with gr.Blocks() as app:
|
| 316 |
gr.Markdown("# ์บ๋กค๋ผ์ธ๋ํ ๊ฐ์ ์ถ์ถ๊ธฐ")
|
|
@@ -367,6 +393,9 @@ with gr.Blocks() as app:
|
|
| 367 |
gr.Markdown("---")
|
| 368 |
gr.Markdown("๋์์ ๊ฐ์ ๋ชฉ๋ก์์ ํ์ํ ๊ฐ์์ URL์ ๋ณต์ฌํด์ ๋ฃ์ด์ฃผ์ธ์")
|
| 369 |
additional_demo.render()
|
|
|
|
|
|
|
|
|
|
| 370 |
|
| 371 |
if __name__ == "__main__":
|
| 372 |
logging.debug("ํตํฉ Gradio ์ฑ ์คํ ์ค")
|
|
|
|
| 221 |
cleaned_text = re.sub(r'^WEBVTT\s*', '', cleaned_text)
|
| 222 |
return cleaned_text
|
| 223 |
|
| 224 |
+
# ์๋ก์ด ์ ์ฒด ์ฒ๋ฆฌ ํจ์: ๊ฐ์ URL -> ์คํฌ๋ฆฝํธ URL ์์ฑ -> ์คํฌ๋ฆฝํธ ๊ฐ์ ธ์ค๊ธฐ -> ํ์๋ผ์ธ ์ ๊ฑฐ
|
| 225 |
+
def process_full(lecture_url):
|
| 226 |
+
"""
|
| 227 |
+
์
๋ ฅ๋ ๊ฐ์ URL๋ก๋ถํฐ ์คํฌ๋ฆฝํธ URL์ ์์ฑํ๊ณ ,
|
| 228 |
+
ํด๋น ์คํฌ๋ฆฝํธ๋ฅผ ๊ฐ์ ธ์จ ํ ํ์๋ผ์ธ์ ์ ๊ฑฐํ ์ต์ข
๊ฐ์ ๋ด์ฉ์ ๋ฐํํ๋ ํจ์.
|
| 229 |
+
์ค๊ฐ ๋จ๊ณ๋ ์ถ๋ ฅํ์ง ์๊ณ ์ต์ข
๊ฒฐ๊ณผ๋ง ๋ฐํํฉ๋๋ค.
|
| 230 |
+
"""
|
| 231 |
+
script_url = create_script_url(lecture_url)
|
| 232 |
+
if not script_url:
|
| 233 |
+
return "์คํฌ๋ฆฝํธ URL ์์ฑ ์คํจ"
|
| 234 |
+
|
| 235 |
+
script_text = fetch_script(script_url)
|
| 236 |
+
if "์ค๋ฅ ๋ฐ์" in script_text:
|
| 237 |
+
return script_text
|
| 238 |
+
|
| 239 |
+
cleaned = remove_timeline(script_text, 1) # lecture_number๋ ๊ธฐ๋ณธ๊ฐ์ผ๋ก 1 ์ฌ์ฉ
|
| 240 |
+
return cleaned
|
| 241 |
+
|
| 242 |
with gr.Blocks() as additional_demo:
|
| 243 |
# ๋ชจ๋2 ์๋จ ์๋ด ๋ฌธ๊ตฌ
|
| 244 |
gr.Markdown("โป ์๋ ์์๋๋ก ๊ฐ ๋จ๊ณ๋ณ ๋ฒํผ์ ๋๋ฌ ์งํํ์ธ์.")
|
|
|
|
| 329 |
gr.Markdown("๋๋ฒ๊น
๋ชจ๋ ํ์ฑํ๋จ: ๋ก๊ทธ๊ฐ ์ฝ์์ ์ถ๋ ฅ๋ฉ๋๋ค.")
|
| 330 |
# ---------- [๋ชจ๋2: ์ถ๊ฐ์ฝ๋] ๋ ----------
|
| 331 |
|
| 332 |
+
# ์๋ก์ด ์ ์ฒด ์ฒ๋ฆฌ ์ธํฐํ์ด์ค: ๊ฐ์ URL -> ํ์๋ผ์ธ ์ ๊ฑฐ ๊ฒฐ๊ณผ๋ง ๋ฐํ
|
| 333 |
+
full_interface = gr.Interface(
|
| 334 |
+
fn=process_full,
|
| 335 |
+
inputs=gr.Textbox(label="๊ฐ์ URL", placeholder="๊ฐ์ URL์ ์
๋ ฅํ์ธ์..."),
|
| 336 |
+
outputs=gr.Textbox(label="ํ์๋ผ์ธ ์ ๊ฑฐ ๊ฒฐ๊ณผ", lines=10),
|
| 337 |
+
description="๊ฐ์ URL์ ์
๋ ฅํ๋ฉด ์คํฌ๋ฆฝํธ URL ์์ฑ, ์คํฌ๋ฆฝํธ ๊ฐ์ ธ์ค๊ธฐ, ํ์๋ผ์ธ ์ ๊ฑฐ๊น์ง ํ ๋ฒ์ ์ํํฉ๋๋ค."
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
# ---------- ํตํฉ Gradio ์ฑ ๊ตฌ์ฑ (ํ ํ์ด์ง์ ๋ชจ๋ ํ์) ----------
|
| 341 |
with gr.Blocks() as app:
|
| 342 |
gr.Markdown("# ์บ๋กค๋ผ์ธ๋ํ ๊ฐ์ ์ถ์ถ๊ธฐ")
|
|
|
|
| 393 |
gr.Markdown("---")
|
| 394 |
gr.Markdown("๋์์ ๊ฐ์ ๋ชฉ๋ก์์ ํ์ํ ๊ฐ์์ URL์ ๋ณต์ฌํด์ ๋ฃ์ด์ฃผ์ธ์")
|
| 395 |
additional_demo.render()
|
| 396 |
+
gr.Markdown("---")
|
| 397 |
+
gr.Markdown("### ์ ์ฒด ์ฒ๋ฆฌ (๊ฐ์ URL -> ํ์๋ผ์ธ ์ ๊ฑฐ)")
|
| 398 |
+
full_interface.render()
|
| 399 |
|
| 400 |
if __name__ == "__main__":
|
| 401 |
logging.debug("ํตํฉ Gradio ์ฑ ์คํ ์ค")
|