Hyper-RVC / app.py
R-Kentaren's picture
fix: app.py - bug fixes for audio loading & validation
8c67742 verified
Raw
History Blame Contribute Delete
2.42 kB
"""
Hyper-RVC Application Entry Point
Launches the Gradio WebUI for AI Voice Conversion
"""
import os
import sys
import subprocess
import logging
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
def check_dependencies():
"""Check if required packages are installed."""
required_packages = ['gradio', 'torch', 'librosa', 'soundfile']
missing = []
for pkg in required_packages:
try:
__import__(pkg)
except ImportError:
missing.append(pkg)
if missing:
logger.warning(f"Missing packages: {missing}. Attempting to install...")
for pkg in missing:
subprocess.check_call([sys.executable, "-m", "pip", "install", pkg])
logger.info("Dependencies installed successfully.")
def download_required_models():
"""Download required AI models for RVC processing."""
logger.info("Checking/downloading required models...")
try:
result = subprocess.run(
[sys.executable, "src/download_models.py"],
cwd=os.path.dirname(os.path.abspath(__file__)),
capture_output=True,
text=True,
timeout=300 # 5 minute timeout
)
if result.returncode != 0:
logger.error(f"Model download error: {result.stderr}")
else:
logger.info("Models ready.")
except subprocess.TimeoutExpired:
logger.warning("Model download timed out. Some features may not work.")
except Exception as e:
logger.error(f"Error during model setup: {e}")
def main():
"""Main entry point for Hyper-RVC application."""
print("="*60)
print(" Hyper-RVC - AI Voice Conversion System")
print("="*60)
print()
# Check and install dependencies
check_dependencies()
# Download required models
download_required_models()
# Parse command line arguments
args = " ".join(sys.argv[1:])
# Launch WebUI
cmd = f"python src/webui.py {args}"
print()
print("🚀 Starting Hyper-RVC WebUI...")
print(" The interface will be available at http://localhost:7860")
print()
print(" Press Ctrl+C to stop the server")
print("-"*60)
os.system(cmd)
if __name__ == "__main__":
main()