das1mtb56 commited on
Commit
0e3b9dd
·
verified ·
1 Parent(s): 60171cf

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -60
app.py DELETED
@@ -1,60 +0,0 @@
1
- import gradio as gr
2
- import whisper
3
- import yt_dlp
4
- import os
5
- from transformers import pipeline
6
-
7
- # Load Whisper model
8
- whisper_model = whisper.load_model("base")
9
-
10
- # Load Summarization pipeline (you can replace with a LLaMA fine-tuned model if you have one)
11
- summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
12
-
13
- def download_youtube_audio(youtube_url):
14
- filename = "audio.mp3"
15
- ydl_opts = {
16
- 'format': 'bestaudio/best',
17
- 'outtmpl': filename,
18
- 'quiet': True,
19
- 'postprocessors': [{
20
- 'key': 'FFmpegExtractAudio',
21
- 'preferredcodec': 'mp3',
22
- 'preferredquality': '192',
23
- }],
24
- }
25
-
26
- with yt_dlp.YoutubeDL(ydl_opts) as ydl:
27
- ydl.download([youtube_url])
28
-
29
- return filename
30
-
31
- def transcribe_and_summarize(youtube_url):
32
- try:
33
- # Step 1: Download audio
34
- audio_file = download_youtube_audio(youtube_url)
35
-
36
- # Step 2: Transcribe
37
- result = whisper_model.transcribe(audio_file)
38
- transcript = result["text"]
39
-
40
- # Step 3: Summarize
41
- summary = summarizer(transcript, max_length=200, min_length=50, do_sample=False)[0]["summary_text"]
42
-
43
- # Clean up
44
- os.remove(audio_file)
45
-
46
- return f"📄 **Transcript:**\n\n{transcript}\n\n🧠 **Summary:**\n\n{summary}"
47
-
48
- except Exception as e:
49
- return f"❌ Error: {str(e)}"
50
-
51
- # Gradio UI
52
- demo = gr.Interface(
53
- fn=transcribe_and_summarize,
54
- inputs=gr.Textbox(label="Enter YouTube Video URL"),
55
- outputs=gr.Markdown(label="Transcript and Summary"),
56
- title="🎥 YouTube Video Summarizer",
57
- description="Enter a YouTube video link. This app will transcribe it and summarize using AI."
58
- )
59
-
60
- demo.launch()