""" Main CLI entry point for Voice Tools. Provides command-line interface for voice extraction and profiling tasks. """ import logging import click from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() # Configure SSL context BEFORE any model-related imports from src.config.ssl_config import configure_ssl_context configure_ssl_context() from .progress import ( display_error, display_header, display_info, display_success, display_warning, ) # Configure logging logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" ) logger = logging.getLogger(__name__) @click.group() @click.version_option(version="0.1.0", prog_name="voice-tools") def cli(): """ Voice Tools - Extract and profile voices from audio files. This tool helps you extract specific voices from audio files using speaker diarization and voice matching. It can separate speech from nonverbal sounds and apply quality filtering. """ pass # Import and register commands from .denoise import denoise from .extract_speaker import extract_speaker from .separate import separate cli.add_command(separate) cli.add_command(extract_speaker) cli.add_command(denoise) @cli.command() @click.option("--host", default="0.0.0.0", help="Server hostname (default: 0.0.0.0)") @click.option("--port", default=7860, type=int, help="Server port (default: 7860)") @click.option("--share", is_flag=True, help="Create public share link") def web(host: str, port: int, share: bool): """ Launch the web interface. Opens a browser-based UI for voice extraction with file upload, configuration, and result download. Example: \b voice-tools web voice-tools web --port 8080 --share """ from ..web.app import launch display_header("Voice Tools - Web Interface") display_info(f"Starting web server on http://{host}:{port}") if share: display_info("Creating public share link...") display_success("Server starting... Open the URL in your browser") try: launch(server_name=host, server_port=port, share=share, debug=False) except KeyboardInterrupt: display_info("Server stopped") except Exception as e: display_error(f"Failed to start server: {e}") raise click.Abort() @cli.command() def info(): """ Display information about Voice Tools. Shows configuration, model information, and system details. """ import torch from rich.table import Table from ..services.model_manager import ModelManager from .progress import console display_header("Voice Tools - System Information") # Version info info_table = Table(title="Version", show_header=False) info_table.add_column("Key", style="cyan") info_table.add_column("Value", style="white") info_table.add_row("Version", "0.1.0") console.print(info_table) console.print() # Models info models_table = Table(title="Models", show_header=False) models_table.add_column("Component", style="cyan") models_table.add_column("Model", style="white") models_table.add_row("Speaker Diarization", "pyannote/speaker-diarization-3.1") models_table.add_row("Voice Embedding", "pyannote/embedding") models_table.add_row("Speech Classifier", "MIT/ast-finetuned-audioset-10-10-0.4593") models_table.add_row("VAD", "Silero VAD v4.0") console.print(models_table) console.print() # Environment info env_table = Table(title="Environment", show_header=False) env_table.add_column("Key", style="cyan") env_table.add_column("Value", style="white") env_table.add_row("PyTorch version", torch.__version__) env_table.add_row("CUDA available", "Yes" if torch.cuda.is_available() else "No") if torch.cuda.is_available(): env_table.add_row("CUDA device", torch.cuda.get_device_name(0)) console.print(env_table) console.print() # Check for HuggingFace token model_manager = ModelManager() token = model_manager.get_hf_token() if token: display_success("HuggingFace token: Configured") else: display_warning("HuggingFace token: Not configured") display_info("Some models require authentication. Set HF_TOKEN environment variable.") def main(): """Entry point for the CLI.""" cli() if __name__ == "__main__": main()