| 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κ° μ€μ λμ§ μμμ΅λλ€. .env νμΌμ νμΈν΄μ£ΌμΈμ." |
| |
| worksheet = YouTubeWorksheet(API_KEY) |
| |
| |
| transcript = worksheet.get_transcript(url) |
| if not transcript: |
| return "μλ§μ μΆμΆν μ μμ΅λλ€." |
| |
| |
| content = worksheet.create_worksheet(transcript) |
| |
| |
| output_file = worksheet.save_to_docx(content) |
| |
| return f"μν¬μνΈκ° μμ±λμμ΅λλ€. νμΌλͺ
: {output_file}", output_file |
|
|
| def main(): |
| |
| iface = gr.Interface( |
| fn=process_video, |
| inputs=[gr.Textbox(label="YouTube URLμ μ
λ ₯νμΈμ")], |
| outputs=[gr.Textbox(label="μ²λ¦¬ κ²°κ³Ό"), gr.File(label="μμ±λ μν¬μνΈ")], |
| title="YouTube νμ΅ μν¬μνΈ μμ±κΈ°", |
| description="YouTube μμμ μλ§μ μ΄μ©νμ¬ νμ΅ μν¬μνΈλ₯Ό μμ±ν©λλ€." |
| ) |
| iface.launch(share=True) |
|
|
| if __name__ == '__main__': |
| load_dotenv() |
| main() |