Spaces:
Runtime error
Runtime error
File size: 3,359 Bytes
68e5689 | 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 | #!/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()
|