Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -465,6 +465,7 @@ async def process_batch_dynamic(wav_files: List[str], start_batch_index: int, ba
|
|
| 465 |
# Upload transcription immediately
|
| 466 |
uploaded_ok = await upload_transcription_to_hf(wav_filename, transcription_result)
|
| 467 |
if uploaded_ok:
|
|
|
|
| 468 |
state["file_states"][wav_filename] = "processed"
|
| 469 |
uploaded_count += 1
|
| 470 |
progress['uploaded_count'] = uploaded_count
|
|
@@ -476,20 +477,22 @@ async def process_batch_dynamic(wav_files: List[str], start_batch_index: int, ba
|
|
| 476 |
else:
|
| 477 |
state["file_states"][wav_filename] = "failed"
|
| 478 |
print(f"[{FLOW_ID}] ❌ Transcription failed for {wav_filename}")
|
| 479 |
-
|
| 480 |
-
# Persist state change for this file to HF
|
| 481 |
-
await upload_hf_state(state)
|
| 482 |
|
| 483 |
except Exception as e:
|
| 484 |
print(f"[{FLOW_ID}] Error processing result for {wav_filename}: {e}")
|
| 485 |
state["file_states"][wav_filename] = "failed"
|
| 486 |
-
await upload_hf_state(state)
|
| 487 |
finally:
|
| 488 |
# Release the server
|
| 489 |
await release_server(server)
|
| 490 |
# Clean up the WAV file
|
| 491 |
if wav_path.exists():
|
| 492 |
wav_path.unlink()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
except Exception as e:
|
| 494 |
print(f"[{FLOW_ID}] Error in process_batch_dynamic: {e}")
|
| 495 |
|
|
|
|
| 465 |
# Upload transcription immediately
|
| 466 |
uploaded_ok = await upload_transcription_to_hf(wav_filename, transcription_result)
|
| 467 |
if uploaded_ok:
|
| 468 |
+
# Update state locally but do NOT upload to HF yet
|
| 469 |
state["file_states"][wav_filename] = "processed"
|
| 470 |
uploaded_count += 1
|
| 471 |
progress['uploaded_count'] = uploaded_count
|
|
|
|
| 477 |
else:
|
| 478 |
state["file_states"][wav_filename] = "failed"
|
| 479 |
print(f"[{FLOW_ID}] ❌ Transcription failed for {wav_filename}")
|
|
|
|
|
|
|
|
|
|
| 480 |
|
| 481 |
except Exception as e:
|
| 482 |
print(f"[{FLOW_ID}] Error processing result for {wav_filename}: {e}")
|
| 483 |
state["file_states"][wav_filename] = "failed"
|
|
|
|
| 484 |
finally:
|
| 485 |
# Release the server
|
| 486 |
await release_server(server)
|
| 487 |
# Clean up the WAV file
|
| 488 |
if wav_path.exists():
|
| 489 |
wav_path.unlink()
|
| 490 |
+
|
| 491 |
+
# --- After all files in this batch are uploaded, update HF state once
|
| 492 |
+
if await upload_hf_state(state):
|
| 493 |
+
print(f"[{FLOW_ID}] ✅ Batch state updated on HF: files {start_batch_index}-{batch_end - 1} marked processed")
|
| 494 |
+
else:
|
| 495 |
+
print(f"[{FLOW_ID}] ❌ Failed to update batch state on HF")
|
| 496 |
except Exception as e:
|
| 497 |
print(f"[{FLOW_ID}] Error in process_batch_dynamic: {e}")
|
| 498 |
|