cytopa99's picture
Upload 47 files
68e5689 verified
#!/usr/bin/env python3
"""
Universal Fast Dubbing Backend Setup Script
"""
import os
import sys
import subprocess
def check_python_version():
"""Check if Python version is 3.8 or higher"""
if sys.version_info < (3, 8):
print("❌ Python 3.8 or higher is required")
sys.exit(1)
print(f"βœ… Python {sys.version_info.major}.{sys.version_info.minor} detected")
def create_venv():
"""Create virtual environment"""
print("\nπŸ“¦ Creating virtual environment...")
try:
subprocess.run([sys.executable, "-m", "venv", "venv"], check=True)
print("βœ… Virtual environment created")
except subprocess.CalledProcessError:
print("❌ Failed to create virtual environment")
sys.exit(1)
def install_dependencies():
"""Install required dependencies"""
print("\nπŸ“₯ Installing dependencies...")
# Determine pip path based on OS
if sys.platform == "win32":
pip_path = os.path.join("venv", "Scripts", "pip")
else:
pip_path = os.path.join("venv", "bin", "pip")
try:
subprocess.run([pip_path, "install", "-r", "requirements.txt"], check=True)
print("βœ… Dependencies installed")
except subprocess.CalledProcessError:
print("❌ Failed to install dependencies")
sys.exit(1)
def check_ffmpeg():
"""Check if FFmpeg is installed"""
print("\n🎡 Checking FFmpeg installation...")
try:
subprocess.run(["ffmpeg", "-version"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True)
print("βœ… FFmpeg is installed")
except (subprocess.CalledProcessError, FileNotFoundError):
print("⚠️ FFmpeg not found. Please install FFmpeg:")
print(" - Windows: https://ffmpeg.org/download.html")
print(" - macOS: brew install ffmpeg")
print(" - Linux: sudo apt-get install ffmpeg")
def create_env_file():
"""Create .env file from template"""
print("\nβš™οΈ Setting up environment configuration...")
if not os.path.exists(".env"):
if os.path.exists(".env.example"):
with open(".env.example", "r") as src:
with open(".env", "w") as dst:
dst.write(src.read())
print("βœ… .env file created from template")
print("⚠️ Please edit .env and add your GROQ_API_KEY")
else:
print("❌ .env.example not found")
else:
print("βœ… .env file already exists")
def main():
"""Main setup function"""
print("=" * 50)
print("Universal Fast Dubbing Backend Setup")
print("=" * 50)
check_python_version()
create_venv()
install_dependencies()
check_ffmpeg()
create_env_file()
print("\n" + "=" * 50)
print("βœ… Setup complete!")
print("=" * 50)
print("\nNext steps:")
print("1. Edit backend/.env and add your GROQ_API_KEY")
print("2. Activate virtual environment:")
if sys.platform == "win32":
print(" venv\\Scripts\\activate")
else:
print(" source venv/bin/activate")
print("3. Run the application:")
print(" python app.py")
if __name__ == "__main__":
main()