JaganathC commited on
Commit
c71ebe4
·
verified ·
1 Parent(s): a1bccac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -11
app.py CHANGED
@@ -47,38 +47,64 @@ def translate_text(text, tgt_lang="es"):
47
  except Exception as e:
48
  return str(e)
49
 
50
- def process_video(video_file, youtube_url):
51
- if youtube_url:
52
- video_path = download_youtube_video(youtube_url)
53
- elif video_file:
54
  video_path = video_file.name
 
 
55
  else:
56
  return "No valid input provided."
57
 
58
  audio_path = extract_audio(video_path)
59
  transcription = transcribe_audio(audio_path)
60
- return transcription
61
 
62
  def summarize_and_translate(text, lang):
63
  summary = summarize_text(text)
64
  translation = translate_text(summary, lang)
65
  return summary, translation
66
 
67
- with gr.Blocks() as app:
68
- gr.Markdown("# 🎥 Smart Video-to-Text Summarization App")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  with gr.Row():
 
71
  video_upload = gr.File(label="Upload Video File", type="filepath")
72
  youtube_link = gr.Textbox(label="YouTube URL")
73
 
74
- process_button = gr.Button("🚀 Process Video")
 
 
75
  transcription_output = gr.Textbox(label="Transcription", interactive=False)
76
- process_button.click(process_video, inputs=[video_upload, youtube_link], outputs=transcription_output)
77
 
78
- summarize_button = gr.Button("📝 Summarize Text")
 
 
79
  summary_output = gr.Textbox(label="Summary", interactive=False)
80
 
81
- translate_button = gr.Button("🌍 Translate Summary")
82
  language_dropdown = gr.Dropdown(choices=["es", "fr", "de", "zh"], label="Select Translation Language")
83
  translated_output = gr.Textbox(label="Translated Summary", interactive=False)
84
 
 
47
  except Exception as e:
48
  return str(e)
49
 
50
+ def process_video(video_file, youtube_url, video_source):
51
+ if video_source == "Local Video" and video_file:
 
 
52
  video_path = video_file.name
53
+ elif video_source == "YouTube" and youtube_url:
54
+ video_path = download_youtube_video(youtube_url)
55
  else:
56
  return "No valid input provided."
57
 
58
  audio_path = extract_audio(video_path)
59
  transcription = transcribe_audio(audio_path)
60
+ return transcription, video_path
61
 
62
  def summarize_and_translate(text, lang):
63
  summary = summarize_text(text)
64
  translation = translate_text(summary, lang)
65
  return summary, translation
66
 
67
+ with gr.Blocks(css="""
68
+ .glass-card {
69
+ background: rgba(255, 255, 255, 0.1);
70
+ backdrop-filter: blur(10px);
71
+ border: 1px solid rgba(255, 255, 255, 0.2);
72
+ border-radius: 20px;
73
+ padding: 2rem;
74
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
75
+ }
76
+ .btn-blue {
77
+ background-color: #007BFF;
78
+ color: white;
79
+ border-radius: 10px;
80
+ }
81
+ .btn-blue:hover {
82
+ background-color: #0056b3;
83
+ }
84
+ .gradient-font {
85
+ background: linear-gradient(90deg, #ff7f50, #ff6347);
86
+ -webkit-background-clip: text;
87
+ color: transparent;
88
+ }
89
+ """) as app:
90
+ gr.Markdown("<h1 class='gradient-font'>🎥 Smart Video-to-Text Summarization App</h1>")
91
 
92
  with gr.Row():
93
+ video_source = gr.Radio(["Local Video", "YouTube"], label="Choose Video Source", value="Local Video")
94
  video_upload = gr.File(label="Upload Video File", type="filepath")
95
  youtube_link = gr.Textbox(label="YouTube URL")
96
 
97
+ video_display = gr.Video(label="Processed Video", visible=False)
98
+
99
+ process_button = gr.Button("🚀 Process Video", elem_classes=["btn-blue"])
100
  transcription_output = gr.Textbox(label="Transcription", interactive=False)
 
101
 
102
+ process_button.click(process_video, inputs=[video_upload, youtube_link, video_source], outputs=[transcription_output, video_display])
103
+
104
+ summarize_button = gr.Button("📝 Summarize Text", elem_classes=["btn-blue"])
105
  summary_output = gr.Textbox(label="Summary", interactive=False)
106
 
107
+ translate_button = gr.Button("🌍 Translate Summary", elem_classes=["btn-blue"])
108
  language_dropdown = gr.Dropdown(choices=["es", "fr", "de", "zh"], label="Select Translation Language")
109
  translated_output = gr.Textbox(label="Translated Summary", interactive=False)
110