asad231 commited on
Commit
1fb8b56
Β·
verified Β·
1 Parent(s): dabe619

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -62
app.py CHANGED
@@ -1,64 +1,3 @@
1
- # import gradio as gr
2
- # from deep_translator import GoogleTranslator
3
- # import re
4
-
5
- # # βœ… Extract video ID from YouTube URL
6
- # def extract_video_id(url):
7
- # regex = r"(?:v=|\/)([0-9A-Za-z_-]{11})"
8
- # match = re.search(regex, url)
9
- # return match.group(1) if match else url.strip()
10
-
11
- # # βœ… Agent 1: Summarizer (Simulated)
12
- # def summarize_youtube(video_url):
13
- # try:
14
- # video_id = extract_video_id(video_url)
15
-
16
- # saved_transcripts = {
17
- # "dQw4w9WgXcQ": "We're no strangers to love. You know the rules and so do I...",
18
- # "F9cTlfD7ZGM": "This is a video about AI agents and how they collaborate.",
19
- # "HMcFwjWVprs": "This presentation explains the GenAI protocol and its future."
20
- # }
21
-
22
- # if video_id not in saved_transcripts:
23
- # return "❌ Transcript not available for this video.", "", ""
24
-
25
- # summary = saved_transcripts[video_id]
26
- # translation = GoogleTranslator(source='auto', target='es').translate(summary)
27
- # video_embed_link = f"https://www.youtube.com/embed/{video_id}"
28
- # return summary, translation, video_embed_link
29
- # except Exception as e:
30
- # return f"❌ Error: {str(e)}", "", ""
31
-
32
- # # βœ… Master Agent Workflow with Embedded YouTube Preview
33
- # def run_agents(url):
34
- # summary, translation, embed = summarize_youtube(url)
35
- # if embed:
36
- # video_html = f'''
37
- # <div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
38
- # <iframe src="{embed}" style="position:absolute;top:0;left:0;width:100%;height:100%;"
39
- # frameborder="0" allowfullscreen></iframe>
40
- # </div>
41
- # '''
42
- # else:
43
- # video_html = ""
44
- # return summary, translation, video_html
45
-
46
- # # βœ… Gradio UI
47
- # with gr.Blocks() as demo:
48
- # gr.Markdown("## πŸŽ₯ AI Agents: YouTube Summary + Spanish Translator")
49
- # gr.Markdown("πŸ”— Enter a YouTube video URL to simulate AI agent collaboration.")
50
-
51
- # input_url = gr.Textbox(label="Paste YouTube Link")
52
- # summary_output = gr.Textbox(label="🧠 English Summary")
53
- # translation_output = gr.Textbox(label="🌍 Spanish Translation")
54
- # video_output = gr.HTML()
55
-
56
- # run_btn = gr.Button("πŸ” Run Agents")
57
- # run_btn.click(fn=run_agents, inputs=input_url, outputs=[summary_output, translation_output, video_output])
58
-
59
- # demo.launch()
60
-
61
-
62
  import gradio as gr
63
  from deep_translator import GoogleTranslator
64
  import re
@@ -101,7 +40,7 @@ def run_agents(url):
101
 
102
  # βœ… Gradio UI
103
  with gr.Blocks() as demo:
104
- gr.Markdown("## πŸŽ₯ AI Agents: YouTube Summary + Spanish Translator")
105
  gr.Markdown("πŸ”— Enter a YouTube video URL to simulate AI agent collaboration.")
106
 
107
  input_url = gr.Textbox(label="Paste YouTube Link")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from deep_translator import GoogleTranslator
3
  import re
 
40
 
41
  # βœ… Gradio UI
42
  with gr.Blocks() as demo:
43
+ gr.Markdown("## πŸŽ₯ AI Agents: YouTube Summary + Spanish Translator + Youtube Video")
44
  gr.Markdown("πŸ”— Enter a YouTube video URL to simulate AI agent collaboration.")
45
 
46
  input_url = gr.Textbox(label="Paste YouTube Link")