Spaces:
Runtime error
Runtime error
Merge branch 'implemented-pro-system' into 'main'
Browse files128 unmodified lines12913013113213313413518 unmodified lines1541551561571581591601614 unmodified lines166167168169170171172173174175176177178179180181182183184185186187188189190254 unmodified lines445446447448449450451128 unmodified linestry:# 1. Setup Modal app and volumemoderation_app = modal.App("Content-Moderation")_ = os.environ.get('MODAL_TOKEN_ID') # Read to ensure environment readiness (kept for parity with process_audio)_ = os.environ.get('MODAL_TOKEN_SECRET')_ = os.environ.get('MODAL_ENVIRONMENT')18 unmodified lines# 4. Call Modal function synchronouslytry:moderation_function = modal.Function.from_name("Content-Moderation", "reception_function")processed_remote_path = moderation_function.remote(input_text=str(notes) if notes is not None else "",video_path=remote_input_path,size=(int(width), int(height)),4 unmodified lineslogger.error(f"Error calling Modal reception_function: {e}")return "Error calling Outpost to trigger processing."if not processed_remote_path or not isinstance(processed_remote_path, str):logger.error("Modal function did not return a valid path to the processed video.")return "Processing failed to return an output path."# 5. Download the processed video to /tmp with UUID filenamelocal_ext = os.path.splitext(processed_remote_path)[1] or ext or ".mp4"local_output_path = f"/tmp/{uuid.uuid4().hex}{local_ext}"try:# Use Modal Volume.read_file to stream the remote file to the local pathwith open(local_output_path, "wb") as dst:for chunk in volume.read_file(processed_remote_path):if chunk:dst.write(chunk)except Exception as e:logger.error(f"Error downloading processed video from Modal Storage using read_file: {e}")return "Error downloading processed video from Cloud Storage."# 6. Return local pathreturn local_output_pathexcept Exception as e:logger.error(f"Unexpected error in process_video: {e}")254 unmodified lines# Third Row: Single Video Outputwith gr.Row(elem_classes="output-section"):cm_video_out = gr.Video(label="Video Output")# Final Row: Process buttonwith gr.Row():128 unmodified lines12913013113213313418 unmodified lines1531541551561571581591604 unmodified lines165166167168169170171172254 unmodified lines427428429430431432433128 unmodified linestry:# 1. Setup Modal app and volume_ = os.environ.get('MODAL_TOKEN_ID') # Read to ensure environment readiness (kept for parity with process_audio)_ = os.environ.get('MODAL_TOKEN_SECRET')_ = os.environ.get('MODAL_ENVIRONMENT')18 unmodified lines# 4. Call Modal function synchronouslytry:moderation_function = modal.Function.from_name("Content-Moderation", "professional_reception_function")moderation_function.spawn(input_text=str(notes) if notes is not None else "",video_path=remote_input_path,size=(int(width), int(height)),4 unmodified lineslogger.error(f"Error calling Modal reception_function: {e}")return "Error calling Outpost to trigger processing."return "Video Request Obtained"except Exception as e:logger.error(f"Unexpected error in process_video: {e}")254 unmodified lines# Third Row: Single Video Outputwith gr.Row(elem_classes="output-section"):cm_video_out = gr.Textbox(label="Output")# Final Row: Process buttonwith gr.Row():
app.py+4-22