Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from youtubesearchpython import VideosSearch, Transcript # Changed import statement
|
2 |
-
import gradio as gr
|
3 |
import openai
|
4 |
import os
|
5 |
|
@@ -46,38 +46,17 @@ def summarize_text(contents, OPENAI_API_KEY):
|
|
46 |
# return response.choices[0].text.strip()
|
47 |
|
48 |
# Function to integrate all the functionalities
|
49 |
-
def summarize_youtube_videos(keyword,OPENAI_API_KEY):
|
50 |
urls = search_youtube_videos(keyword)
|
51 |
contents = get_transcript(urls)
|
52 |
summary = summarize_text(contents,OPENAI_API_KEY)
|
53 |
return summary
|
54 |
|
55 |
-
def summarize_button_click(keyword, OPENAI_API_KEY):
|
56 |
-
summary = summarize_youtube_videos(keyword, OPENAI_API_KEY)
|
57 |
-
return summary
|
58 |
-
|
59 |
-
# # Define Gradio interface
|
60 |
-
# iface = gr.Interface(
|
61 |
-
# input = gr.Textbox(label="keyword", placeholder='ํค์๋๋ฅผ ์
๋ ฅํ์ธ์. (์.๋นํธ์ฝ์ธ)'),
|
62 |
-
# OPENAI_API_KEY = gr.Textbox(label="OpenAI API ํค", placeholder="์ฌ๊ธฐ์ OpenAI API ํค๋ฅผ ์
๋ ฅํ์ธ์"),
|
63 |
-
# output =gr.JSON(label='์ ํ๋ธ 5๊ฐ ์์ฝ ๊ฒฐ๊ณผ'),
|
64 |
-
# result = gr.Button('submit'),
|
65 |
-
# result.click(
|
66 |
-
# fn = summarize_youtube_videos,
|
67 |
-
# inputs = [input, OPEN_API_KEY],
|
68 |
-
# outputs = [output]
|
69 |
-
# ),
|
70 |
-
# title="Summarize YouTube Videos",
|
71 |
-
# description="Enter a keyword to summarize related YouTube videos.")
|
72 |
-
|
73 |
-
# # Launch Gradio interface
|
74 |
-
# iface.launch()
|
75 |
-
|
76 |
# Define Gradio interface
|
77 |
iface = gr.Interface(
|
78 |
inputs=[
|
79 |
gr.Textbox(label="keyword", placeholder='ํค์๋๋ฅผ ์
๋ ฅํ์ธ์. (์.๋นํธ์ฝ์ธ)'),
|
80 |
-
gr.Textbox(label="OpenAI API ํค", placeholder="์ฌ๊ธฐ์ OpenAI API ํค๋ฅผ ์
๋ ฅํ์ธ์",
|
81 |
],
|
82 |
outputs=gr.JSON(label='์ ํ๋ธ 5๊ฐ ์์ฝ ๊ฒฐ๊ณผ'),
|
83 |
title="Summarize YouTube Videos",
|
@@ -85,6 +64,9 @@ iface = gr.Interface(
|
|
85 |
fn=summarize_button_click # ํด๋ฆญ ์ด๋ฒคํธ๋ฅผ ์ฒ๋ฆฌํ๋ ํจ์๋ฅผ ์ฌ๊ธฐ์ ์ ์ํฉ๋๋ค.
|
86 |
)
|
87 |
|
|
|
|
|
|
|
88 |
|
89 |
# Launch Gradio interface
|
90 |
iface.launch()
|
|
|
1 |
from youtubesearchpython import VideosSearch, Transcript # Changed import statement
|
2 |
+
import gradio as gr
|
3 |
import openai
|
4 |
import os
|
5 |
|
|
|
46 |
# return response.choices[0].text.strip()
|
47 |
|
48 |
# Function to integrate all the functionalities
|
49 |
+
def summarize_youtube_videos(keyword, OPENAI_API_KEY):
|
50 |
urls = search_youtube_videos(keyword)
|
51 |
contents = get_transcript(urls)
|
52 |
summary = summarize_text(contents,OPENAI_API_KEY)
|
53 |
return summary
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
# Define Gradio interface
|
56 |
iface = gr.Interface(
|
57 |
inputs=[
|
58 |
gr.Textbox(label="keyword", placeholder='ํค์๋๋ฅผ ์
๋ ฅํ์ธ์. (์.๋นํธ์ฝ์ธ)'),
|
59 |
+
gr.Textbox(label="OpenAI API ํค", placeholder="์ฌ๊ธฐ์ OpenAI API ํค๋ฅผ ์
๋ ฅํ์ธ์"),
|
60 |
],
|
61 |
outputs=gr.JSON(label='์ ํ๋ธ 5๊ฐ ์์ฝ ๊ฒฐ๊ณผ'),
|
62 |
title="Summarize YouTube Videos",
|
|
|
64 |
fn=summarize_button_click # ํด๋ฆญ ์ด๋ฒคํธ๋ฅผ ์ฒ๋ฆฌํ๋ ํจ์๋ฅผ ์ฌ๊ธฐ์ ์ ์ํฉ๋๋ค.
|
65 |
)
|
66 |
|
67 |
+
def summarize_button_click(keyword, OPENAI_API_KEY):
|
68 |
+
summary = summarize_youtube_videos(keyword, OPENAI_API_KEY)
|
69 |
+
return summary
|
70 |
|
71 |
# Launch Gradio interface
|
72 |
iface.launch()
|