|
from youtube_worksheet import YouTubeWorksheet |
|
from dotenv import load_dotenv |
|
import gradio as gr |
|
import os |
|
|
|
def process_video(url): |
|
|
|
API_KEY = os.getenv('GEMINI_API_KEY') |
|
|
|
if not API_KEY: |
|
return "ERROR: GEMINI_API_KEYκ° μ€μ λμ§ μμμ΅λλ€.", None |
|
|
|
worksheet = YouTubeWorksheet(API_KEY) |
|
|
|
|
|
transcript = worksheet.get_transcript(url) |
|
if not transcript: |
|
return "μλ§μ μΆμΆν μ μμ΅λλ€.", None |
|
|
|
|
|
content = worksheet.create_worksheet(transcript) |
|
|
|
|
|
output_file = worksheet.save_to_docx(content) |
|
|
|
return f"μν¬μνΈκ° μμ±λμμ΅λλ€. νμΌλͺ
: {output_file}", output_file |
|
|
|
|
|
load_dotenv() |
|
iface = gr.Interface( |
|
fn=process_video, |
|
inputs=[gr.Textbox(label="YouTube URLμ μ
λ ₯νμΈμ", placeholder="https://www.youtube.com/watch?v=...")], |
|
outputs=[ |
|
gr.Textbox(label="μ²λ¦¬ κ²°κ³Ό"), |
|
gr.File(label="μμ±λ μν¬μνΈ") |
|
], |
|
title="YouTube νμ΅ μν¬μνΈ μμ±κΈ°", |
|
description="YouTube μμμ μλ§μ μ΄μ©νμ¬ νμ΅ μν¬μνΈλ₯Ό μμ±ν©λλ€." |
|
) |
|
|
|
if __name__ == "__main__": |
|
iface.launch() |