@@ -518,7 +518,8 @@ def run_gradio(self):
518518 file_types = [".mp3" , ".wav" , ".flac" , ".m4a" ], # Explicit extensions instead of ["audio"]
519519 file_count = "single" ,
520520 value = None , # Explicitly set to None to avoid Modal's root directory bug
521- show_label = True
521+ show_label = True ,
522+ interactive = True
522523 )
523524 predict_btn = gradio_module .Button ("Detect" , variant = "primary" , size = "lg" )
524525
@@ -646,6 +647,15 @@ def safe_predict(audio_file):
646647 # Set max_file_size attribute if it doesn't exist (for file uploads)
647648 if not hasattr (demo , 'max_file_size' ):
648649 demo .max_file_size = 100 # 100MB default
650+
651+ # Set root_path to empty string for Modal to prevent '/' path issues
652+ # This prevents Gradio from trying to process '/' as a file path on page load
653+ if hasattr (demo , 'root_path' ):
654+ demo .root_path = ""
655+ elif hasattr (demo , 'config' ):
656+ # Try setting it via config if available
657+ if hasattr (demo .config , 'root_path' ):
658+ demo .config .root_path = ""
649659
650660 return demo
651661
@@ -783,6 +793,17 @@ def gradio_app_modal():
783793 demo = interface .run_gradio ()
784794
785795 # In Gradio 4.x, Blocks implements the ASGI interface directly
796+ # Set root_path to empty string to prevent '/' path issues in Modal
797+ # This is similar to setting root_path="" in demo.launch() but for ASGI deployment
798+ try :
799+ if hasattr (demo , 'root_path' ):
800+ demo .root_path = ""
801+ # Also try setting via config if available
802+ if hasattr (demo , 'config' ) and hasattr (demo .config , 'root_path' ):
803+ demo .config .root_path = ""
804+ except Exception :
805+ pass # If setting fails, continue anyway - not critical
806+
786807 # Return the Blocks object directly - it's the ASGI app
787808 # Don't return demo.app as it breaks internal Gradio functionality (like max_file_size)
788809 if not callable (demo ):
0 commit comments