Spaces:
Build error
Build error
juancopi81
commited on
Commit
•
f765cc5
1
Parent(s):
5506a96
Fix share button
Browse files- README.md +1 -1
- app.py +3 -3
- share_btn.py +14 -4
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: YouTube to
|
3 |
emoji: 🏢
|
4 |
colorFrom: indigo
|
5 |
colorTo: red
|
|
|
1 |
---
|
2 |
+
title: YouTube to Video Summary
|
3 |
emoji: 🏢
|
4 |
colorFrom: indigo
|
5 |
colorTo: red
|
app.py
CHANGED
@@ -235,7 +235,7 @@ with block as demo:
|
|
235 |
</h1>
|
236 |
</div>
|
237 |
<p style="margin-bottom: 10px; font-size: 94%">
|
238 |
-
Enter the URL of a YouTube video (in Spanish or English) and you'll
|
239 |
It works for audio books, history lessons, etc. Try it out with a short video (less than 4 minutes). SEE SOME EXAMPLES AT THE BOTTOM.
|
240 |
</p>
|
241 |
<p style="margin-bottom: 10px; font-size: 94%">
|
@@ -247,7 +247,7 @@ with block as demo:
|
|
247 |
with gr.Group():
|
248 |
with gr.Box():
|
249 |
with gr.Row(elem_id="setting_id").style(mobile_collapse=False, equal_height=True):
|
250 |
-
gr.HTML("<h1>
|
251 |
with gr.Row():
|
252 |
with gr.Column():
|
253 |
video_language = gr.Radio(choices=["Spanish", "English"],
|
@@ -279,7 +279,7 @@ with block as demo:
|
|
279 |
margin=False,
|
280 |
rounded=(False, True, True, False),
|
281 |
)
|
282 |
-
video_output = gr.Video()
|
283 |
file_output = gr.File()
|
284 |
|
285 |
btn.click(datapipeline,
|
|
|
235 |
</h1>
|
236 |
</div>
|
237 |
<p style="margin-bottom: 10px; font-size: 94%">
|
238 |
+
Enter the URL of a YouTube video (in Spanish or English) and you'll recieve a video with an illustraded summary (in Spanish or English, it works as translator).
|
239 |
It works for audio books, history lessons, etc. Try it out with a short video (less than 4 minutes). SEE SOME EXAMPLES AT THE BOTTOM.
|
240 |
</p>
|
241 |
<p style="margin-bottom: 10px; font-size: 94%">
|
|
|
247 |
with gr.Group():
|
248 |
with gr.Box():
|
249 |
with gr.Row(elem_id="setting_id").style(mobile_collapse=False, equal_height=True):
|
250 |
+
gr.HTML("<h1>Settings</h1>")
|
251 |
with gr.Row():
|
252 |
with gr.Column():
|
253 |
video_language = gr.Radio(choices=["Spanish", "English"],
|
|
|
279 |
margin=False,
|
280 |
rounded=(False, True, True, False),
|
281 |
)
|
282 |
+
video_output = gr.Video(elem_id="output-video")
|
283 |
file_output = gr.File()
|
284 |
|
285 |
btn.click(datapipeline,
|
share_btn.py
CHANGED
@@ -22,6 +22,13 @@ share_js = """async () => {
|
|
22 |
const url = await response.text();
|
23 |
return url;
|
24 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
async function getInputImgFile(imgEl){
|
26 |
const res = await fetch(imgEl.src);
|
27 |
const blob = await res.blob();
|
@@ -57,6 +64,7 @@ share_js = """async () => {
|
|
57 |
const gradioEl = document.querySelector('body > gradio-app');
|
58 |
// const gradioEl = document.querySelector("gradio-app").shadowRoot;
|
59 |
const inputPromptEl = gradioEl.querySelector('#prompt-in textarea').value;
|
|
|
60 |
const outputImgEl = gradioEl.querySelector('#img-out img');
|
61 |
const outputMusic = gradioEl.querySelector('#music-out audio');
|
62 |
const outputMusic_src = gradioEl.querySelector('#music-out audio').src;
|
@@ -68,20 +76,22 @@ share_js = """async () => {
|
|
68 |
const shareBtnEl = gradioEl.querySelector('#share-btn');
|
69 |
const shareIconEl = gradioEl.querySelector('#share-btn-share-icon');
|
70 |
const loadingIconEl = gradioEl.querySelector('#share-btn-loading-icon');
|
71 |
-
if(!
|
72 |
return;
|
73 |
};
|
74 |
shareBtnEl.style.pointerEvents = 'none';
|
75 |
shareIconEl.style.display = 'none';
|
76 |
loadingIconEl.style.removeProperty('display');
|
|
|
|
|
77 |
const outputImg = await getInputImgFile(outputImgEl);
|
78 |
const urlOutputImg = await uploadFile(outputImg);
|
79 |
const musicFile = await getOutputMusicFile(outputMusic);
|
80 |
const dataOutputMusic = await uploadFile(musicFile);
|
81 |
|
82 |
-
const descriptionMd = `####
|
83 |
<img src='${urlOutputImg}' style='max-height: 350px;'>
|
84 |
-
|
85 |
<audio controls>
|
86 |
<source src="${dataOutputMusic}" type="audio/wav">
|
87 |
Your browser does not support the audio element.
|
@@ -92,7 +102,7 @@ Your browser does not support the audio element.
|
|
92 |
description: descriptionMd,
|
93 |
});
|
94 |
const paramsStr = params.toString();
|
95 |
-
window.open(`https://huggingface.co/spaces/
|
96 |
shareBtnEl.style.removeProperty('pointer-events');
|
97 |
shareIconEl.style.removeProperty('display');
|
98 |
loadingIconEl.style.display = 'none';
|
|
|
22 |
const url = await response.text();
|
23 |
return url;
|
24 |
}
|
25 |
+
async function getInputVideoFile(videoEl){
|
26 |
+
const res = await fetch(videoEl.src);
|
27 |
+
const blob = await res.blob();
|
28 |
+
const videoId = Date.now() % 200;
|
29 |
+
const fileName = `sd-perception-${{videoId}}.mp4`;
|
30 |
+
return new File([blob], fileName, { type: 'video/mp4' });
|
31 |
+
}
|
32 |
async function getInputImgFile(imgEl){
|
33 |
const res = await fetch(imgEl.src);
|
34 |
const blob = await res.blob();
|
|
|
64 |
const gradioEl = document.querySelector('body > gradio-app');
|
65 |
// const gradioEl = document.querySelector("gradio-app").shadowRoot;
|
66 |
const inputPromptEl = gradioEl.querySelector('#prompt-in textarea').value;
|
67 |
+
const outputVideoEl = gradioEl.querySelector('#output-video video');
|
68 |
const outputImgEl = gradioEl.querySelector('#img-out img');
|
69 |
const outputMusic = gradioEl.querySelector('#music-out audio');
|
70 |
const outputMusic_src = gradioEl.querySelector('#music-out audio').src;
|
|
|
76 |
const shareBtnEl = gradioEl.querySelector('#share-btn');
|
77 |
const shareIconEl = gradioEl.querySelector('#share-btn-share-icon');
|
78 |
const loadingIconEl = gradioEl.querySelector('#share-btn-loading-icon');
|
79 |
+
if(!outputVideoEl){
|
80 |
return;
|
81 |
};
|
82 |
shareBtnEl.style.pointerEvents = 'none';
|
83 |
shareIconEl.style.display = 'none';
|
84 |
loadingIconEl.style.removeProperty('display');
|
85 |
+
const outputVideo = await getInputVideoFile(outputVideoEl);
|
86 |
+
const urlOutputVideo = await uploadFile(outputVideo);
|
87 |
const outputImg = await getInputImgFile(outputImgEl);
|
88 |
const urlOutputImg = await uploadFile(outputImg);
|
89 |
const musicFile = await getOutputMusicFile(outputMusic);
|
90 |
const dataOutputMusic = await uploadFile(musicFile);
|
91 |
|
92 |
+
const descriptionMd = `#### Here is my AI generated Video Summary:
|
93 |
<img src='${urlOutputImg}' style='max-height: 350px;'>
|
94 |
+
|
95 |
<audio controls>
|
96 |
<source src="${dataOutputMusic}" type="audio/wav">
|
97 |
Your browser does not support the audio element.
|
|
|
102 |
description: descriptionMd,
|
103 |
});
|
104 |
const paramsStr = params.toString();
|
105 |
+
window.open(`https://huggingface.co/spaces/juancopi81/whisper-demo-es-medium/discussions/new?${paramsStr}`, '_blank');
|
106 |
shareBtnEl.style.removeProperty('pointer-events');
|
107 |
shareIconEl.style.removeProperty('display');
|
108 |
loadingIconEl.style.display = 'none';
|