File size: 1,327 Bytes
24238f5 1a84c5a 24238f5 1a84c5a 24238f5 1a84c5a 24238f5 1a84c5a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
from youtube_worksheet import YouTubeWorksheet
from dotenv import load_dotenv
import gradio as gr
import os
def process_video(url):
# νκ²½λ³μμμ API ν€ κ°μ Έμ€κΈ°
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)
# DOCX νμΌλ‘ μ μ₯
output_file = worksheet.save_to_docx(content)
return f"μν¬μνΈκ° μμ±λμμ΅λλ€. νμΌλͺ
: {output_file}", output_file
def main():
# Gradio μΈν°νμ΄μ€ μ€ν
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() |