romizone commited on
Commit
0daa25a
Β·
verified Β·
1 Parent(s): 22339cd

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +30 -19
app.py CHANGED
@@ -983,30 +983,41 @@ window.stopTranscribeTimer=function(ok){
983
  },60000);
984
  };
985
 
986
- /* Auto-start timer on Gradio progress indicator (server-side signal).
987
- This ensures timer ONLY starts after validation passes:
988
- - No file β†’ gr.Error() before progress() β†’ no progress element β†’ timer never starts
989
- - File OK β†’ progress(0.05) β†’ progress element added β†’ timer starts */
 
 
 
990
  new MutationObserver(function(muts){
991
  muts.forEach(function(m){
992
- m.addedNodes.forEach(function(n){
993
- if(n.nodeType===1){
994
- /* Detect Gradio progress β†’ start timer (only once) */
995
- var isProgress=n.classList&&(n.classList.contains('progress-level')||n.classList.contains('eta-bar'));
996
- var hasProgress=n.querySelector&&n.querySelector('.progress-level,.eta-bar');
997
- if((isProgress||hasProgress)&&!window._timerInterval){
998
- window.startTranscribeTimer();
 
 
 
 
 
 
999
  }
1000
- /* Detect error toast β†’ stop timer */
1001
- var isToast=n.classList&&(n.classList.contains('toast-wrap')||n.classList.contains('error'));
1002
- var hasError=n.querySelector&&n.querySelector('.error,.toast-body');
1003
- if((isToast||hasError)&&window._timerInterval){
1004
- window.stopTranscribeTimer(false);
1005
  }
1006
- }
1007
- });
 
 
 
 
1008
  });
1009
- }).observe(document.body,{childList:true,subtree:true});
1010
  </script>
1011
  """
1012
 
 
983
  },60000);
984
  };
985
 
986
+ /* Auto-start timer when EXPLICIT progress() text appears (contains ⏳).
987
+ Gradio StatusTracker (.eta-bar, .progress-level) appears on ALL fn calls,
988
+ but our ⏳ marker only appears when progress(0.05,"⏳ Menunggu GPU...") is called,
989
+ which happens AFTER the audio_file validation passes.
990
+ - No file β†’ gr.Error() before progress() β†’ no ⏳ β†’ timer never starts
991
+ - File OK β†’ progress(0.05,"⏳...") β†’ ⏳ detected β†’ timer starts
992
+ Auto-stop on error toast. */
993
  new MutationObserver(function(muts){
994
  muts.forEach(function(m){
995
+ if(m.type==='childList'){
996
+ m.addedNodes.forEach(function(n){
997
+ /* Element node: check text for ⏳ marker */
998
+ if(n.nodeType===1){
999
+ if(!window._timerInterval&&n.textContent&&n.textContent.indexOf('\u23f3')!==-1){
1000
+ window.startTranscribeTimer();
1001
+ }
1002
+ /* Detect error toast β†’ stop timer */
1003
+ var isToast=n.classList&&(n.classList.contains('toast-wrap')||n.classList.contains('error'));
1004
+ var hasError=n.querySelector&&n.querySelector('.error,.toast-body');
1005
+ if((isToast||hasError)&&window._timerInterval){
1006
+ window.stopTranscribeTimer(false);
1007
+ }
1008
  }
1009
+ /* Text node with ⏳ */
1010
+ if(n.nodeType===3&&!window._timerInterval&&n.nodeValue&&n.nodeValue.indexOf('\u23f3')!==-1){
1011
+ window.startTranscribeTimer();
 
 
1012
  }
1013
+ });
1014
+ }
1015
+ /* Text content change containing ⏳ (progress update on existing node) */
1016
+ if(m.type==='characterData'&&!window._timerInterval&&m.target.nodeValue&&m.target.nodeValue.indexOf('\u23f3')!==-1){
1017
+ window.startTranscribeTimer();
1018
+ }
1019
  });
1020
+ }).observe(document.body,{childList:true,subtree:true,characterData:true});
1021
  </script>
1022
  """
1023