mahesh1209 commited on
Commit
c8dedad
·
verified ·
1 Parent(s): 46a080f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +46 -17
index.html CHANGED
@@ -1,19 +1,48 @@
1
- <!doctype html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
  <html>
3
+ <head>
4
+ <title>YouTube Summarizer</title>
5
+ </head>
6
+ <body>
7
+ <h2>Summarize a YouTube Video</h2>
8
+ <input type="text" id="youtubeUrl" placeholder="Paste YouTube URL">
9
+ <button onclick="summarizeVideo()">Summarize</button>
10
+ <pre id="summaryOutput"></pre>
11
+
12
+ <script>
13
+ async function summarizeVideo() {
14
+ const url = document.getElementById('youtubeUrl').value;
15
+ const videoId = extractVideoID(url);
16
+ if (!videoId) return alert("Invalid YouTube URL");
17
+
18
+ const transcript = await fetchTranscript(videoId);
19
+ const summary = await summarizeText(transcript);
20
+ document.getElementById('summaryOutput').textContent = summary;
21
+ }
22
+
23
+ function extractVideoID(url) {
24
+ const match = url.match(/(?:v=|\/)([0-9A-Za-z_-]{11})/);
25
+ return match ? match[1] : null;
26
+ }
27
+
28
+ async function fetchTranscript(videoId) {
29
+ const response = await fetch(`https://youtubetranscriptapi.streamlit.app/api/transcript/${videoId}`);
30
+ const data = await response.json();
31
+ return data.transcript.map(t => t.text).join(' ');
32
+ }
33
+
34
+ async function summarizeText(text) {
35
+ const response = await fetch('https://api-inference.huggingface.co/models/facebook/bart-large-cnn', {
36
+ method: 'POST',
37
+ headers: {
38
+ 'Authorization': 'Bearer YOUR_HF_API_KEY',
39
+ 'Content-Type': 'application/json'
40
+ },
41
+ body: JSON.stringify({ inputs: text })
42
+ });
43
+ const result = await response.json();
44
+ return result[0]?.summary_text || "No summary available";
45
+ }
46
+ </script>
47
+ </body>
48
  </html>