fffiloni commited on
Commit
f699189
1 Parent(s): 39735ea

Update share_btn.py

Browse files
Files changed (1) hide show
  1. share_btn.py +5 -13
share_btn.py CHANGED
@@ -28,7 +28,7 @@ share_js = """async () => {
28
  const res = await fetch(videoEL.src, { mode: 'no-cors'});
29
  const blob = await res.blob();
30
  //const videoId = Date.now() % 200;
31
- const fileName = `talking-portrait-${videoName}.mp4`;
32
  const videoBlob = new File([blob], fileName, { type: 'video/mpeg' });
33
 
34
  console.log(videoBlob);
@@ -39,15 +39,7 @@ share_js = """async () => {
39
 
40
  }
41
 
42
- async function videoToBase64(videoFile) {
43
- return new Promise((resolve, reject) => {
44
- let reader = new FileReader();
45
- reader.readAsDataURL(videoFile);
46
- reader.onload = () => resolve(reader.result);
47
- reader.onerror = error => reject(error);
48
-
49
- });
50
- }
51
 
52
  //const gradioEl = document.querySelector('body > gradio-app');
53
  const gradioEl = document.querySelector("gradio-app").shadowRoot;
@@ -57,6 +49,8 @@ share_js = """async () => {
57
  const outputVideo = gradioEl.querySelector('#video_out video');
58
  const outputVideo_src = gradioEl.querySelector('#video_out video').src;
59
  const outputVideo_name = outputVideo_src.split('/').pop();
 
 
60
 
61
  let titleTxt = outputVideo_name;
62
 
@@ -76,9 +70,7 @@ share_js = """async () => {
76
  shareIconEl.style.display = 'none';
77
  loadingIconEl.style.removeProperty('display');
78
 
79
- const videoFile = await getOutputVideoFile(outputVideo, outputVideo_name);
80
- const video64 = await videoToBase64(videoFile)
81
- console.log(video64)
82
  const dataOutputVideo = await uploadFile(videoFile);
83
 
84
 
 
28
  const res = await fetch(videoEL.src, { mode: 'no-cors'});
29
  const blob = await res.blob();
30
  //const videoId = Date.now() % 200;
31
+ const fileName = `talking-portrait-${videoName}`;
32
  const videoBlob = new File([blob], fileName, { type: 'video/mpeg' });
33
 
34
  console.log(videoBlob);
 
39
 
40
  }
41
 
42
+
 
 
 
 
 
 
 
 
43
 
44
  //const gradioEl = document.querySelector('body > gradio-app');
45
  const gradioEl = document.querySelector("gradio-app").shadowRoot;
 
49
  const outputVideo = gradioEl.querySelector('#video_out video');
50
  const outputVideo_src = gradioEl.querySelector('#video_out video').src;
51
  const outputVideo_name = outputVideo_src.split('/').pop();
52
+
53
+ const video_url = "https://fffiloni-one-shot-talking-face.hf.space/file=/tmp/" + ${outputVideo_name}
54
 
55
  let titleTxt = outputVideo_name;
56
 
 
70
  shareIconEl.style.display = 'none';
71
  loadingIconEl.style.removeProperty('display');
72
 
73
+ const videoFile = await getOutputVideoFile(video_url, outputVideo_name);
 
 
74
  const dataOutputVideo = await uploadFile(videoFile);
75
 
76