Spaces:
Running
Running
Update index.html
Browse files- index.html +46 -17
index.html
CHANGED
|
@@ -1,19 +1,48 @@
|
|
| 1 |
-
<!
|
| 2 |
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>
|