Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -342,6 +342,11 @@ function generateClone(){
|
|
| 342 |
btn.textContent = 'Cloning...';
|
| 343 |
status.textContent = '';
|
| 344 |
player.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
fetch('/clone',{
|
| 346 |
method:'POST',
|
| 347 |
headers:{'Content-Type':'application/json'},
|
|
@@ -353,12 +358,18 @@ function generateClone(){
|
|
| 353 |
})
|
| 354 |
.then(function(r){ if(!r.ok) throw new Error('Clone failed'); return r.blob(); })
|
| 355 |
.then(function(blob){
|
|
|
|
|
|
|
| 356 |
player.src = URL.createObjectURL(blob);
|
| 357 |
player.style.display = 'block';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
player.play();
|
| 359 |
-
status.textContent = '● Ready';
|
| 360 |
})
|
| 361 |
.catch(function(e){
|
|
|
|
| 362 |
status.style.color='#e74c3c';
|
| 363 |
status.textContent = 'Error: ' + e.message;
|
| 364 |
})
|
|
|
|
| 342 |
btn.textContent = 'Cloning...';
|
| 343 |
status.textContent = '';
|
| 344 |
player.style.display = 'none';
|
| 345 |
+
var startTime = Date.now();
|
| 346 |
+
var timer = setInterval(function(){
|
| 347 |
+
status.style.color = '#c9a040';
|
| 348 |
+
status.textContent = '⏱ ' + ((Date.now()-startTime)/1000).toFixed(1) + 's';
|
| 349 |
+
}, 100);
|
| 350 |
fetch('/clone',{
|
| 351 |
method:'POST',
|
| 352 |
headers:{'Content-Type':'application/json'},
|
|
|
|
| 358 |
})
|
| 359 |
.then(function(r){ if(!r.ok) throw new Error('Clone failed'); return r.blob(); })
|
| 360 |
.then(function(blob){
|
| 361 |
+
clearInterval(timer);
|
| 362 |
+
var genTime = ((Date.now()-startTime)/1000).toFixed(1);
|
| 363 |
player.src = URL.createObjectURL(blob);
|
| 364 |
player.style.display = 'block';
|
| 365 |
+
player.onloadedmetadata = function(){
|
| 366 |
+
status.style.color = '#4caf50';
|
| 367 |
+
status.textContent = '● Ready — generated in ' + genTime + 's, clip length ' + player.duration.toFixed(1) + 's';
|
| 368 |
+
};
|
| 369 |
player.play();
|
|
|
|
| 370 |
})
|
| 371 |
.catch(function(e){
|
| 372 |
+
clearInterval(timer);
|
| 373 |
status.style.color='#e74c3c';
|
| 374 |
status.textContent = 'Error: ' + e.message;
|
| 375 |
})
|