""" Gradio web interface for Voice Tools. Provides a user-friendly web UI for uploading audio files, configuring extraction parameters, and downloading results. """ import logging # Configure SSL context BEFORE any imports that might trigger model downloads from src.config.ssl_config import configure_ssl_context configure_ssl_context() import gradio as gr from src.web.tabs.speaker_extraction import create_speaker_extraction_tab from src.web.tabs.speaker_separation import create_speaker_separation_tab from src.web.tabs.voice_clipper import create_voice_clipper_tab from src.web.tabs.voice_denoising import create_voice_denoising_tab logger = logging.getLogger(__name__) # Custom CSS for better styling custom_css = """ .container { max-width: 1200px; margin: auto; } .header { text-align: center; padding: 20px; } .footer { text-align: center; padding: 10px; color: #666; } """ def create_app() -> gr.Blocks: """ Create and configure the Gradio web interface. Returns: Configured Gradio Blocks app """ with gr.Blocks(title="Voice Tools") as app: # Header gr.Markdown( """ # 🎤 Voice Tools Extract and profile specific voices from audio files using AI-powered speaker diarization and voice matching. Choose a workflow below to get started. """ ) # Create tabs for different workflows with gr.Tabs(): # Tab 1: Speaker Separation create_speaker_separation_tab() # Tab 2: Speaker Extraction create_speaker_extraction_tab() # Tab 3: Voice Denoising create_voice_denoising_tab() # Tab 4: Voice Clipper (client-side manual trim & stitch) create_voice_clipper_tab() # Footer gr.Markdown( """ --- """, elem_classes=["footer"], ) return app def launch( server_name: str = "0.0.0.0", server_port: int = 7860, share: bool = False, debug: bool = False ): """ Launch the Gradio web interface. Args: server_name: Server hostname (default: 0.0.0.0) server_port: Server port (default: 7860) share: Create public share link (default: False) debug: Enable debug mode (default: False) """ if debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) app = create_app() logger.info(f"Launching Voice Tools web interface on {server_name}:{server_port}") app.launch( server_name=server_name, server_port=server_port, share=share, show_error=True, ) if __name__ == "__main__": launch(debug=True)