Spaces:
Running
Running
File size: 4,439 Bytes
cb39c05 03cad88 cb39c05 95e1515 cb39c05 03cad88 cb39c05 03cad88 cb39c05 03cad88 cb39c05 03cad88 cb39c05 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | """
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()
|