| | import argparse |
| | import os |
| | import subprocess |
| | import sys |
| |
|
| | script_dir = os.getcwd() |
| |
|
| |
|
| | def run_cmd(cmd, capture_output=False, env=None): |
| | |
| | return subprocess.run(cmd, shell=True, capture_output=capture_output, env=env) |
| |
|
| |
|
| | def check_env(): |
| | |
| | conda_not_exist = run_cmd("conda", capture_output=True).returncode |
| | if conda_not_exist: |
| | print("Conda is not installed. Exiting...") |
| | sys.exit() |
| |
|
| | |
| | if os.environ["CONDA_DEFAULT_ENV"] == "base": |
| | print("Create an environment for this project and activate it. Exiting...") |
| | sys.exit() |
| |
|
| |
|
| | def install_dependencies(): |
| | |
| | print("What is your GPU") |
| | print() |
| | print("A) NVIDIA") |
| | print("B) AMD") |
| | print("C) Apple M Series") |
| | print("D) None (I want to run in CPU mode)") |
| | print() |
| | gpuchoice = input("Input> ").lower() |
| |
|
| | |
| | if gpuchoice == "a": |
| | run_cmd( |
| | "conda install -y -k pytorch[version=2,build=py3.10_cuda11.7*] torchvision torchaudio pytorch-cuda=11.7 cuda-toolkit ninja git -c pytorch -c nvidia/label/cuda-11.7.0 -c nvidia" |
| | ) |
| | elif gpuchoice == "b": |
| | print("AMD GPUs are not supported. Exiting...") |
| | sys.exit() |
| | elif gpuchoice == "c" or gpuchoice == "d": |
| | run_cmd( |
| | "conda install -y -k pytorch torchvision torchaudio cpuonly git -c pytorch" |
| | ) |
| | else: |
| | print("Invalid choice. Exiting...") |
| | sys.exit() |
| |
|
| | |
| | run_cmd("conda install -y -c pytorch ffmpeg") |
| | run_cmd("conda install -y -c conda-forge nodejs=18.16.1") |
| | run_cmd("git clone https://github.com/rsxdalv/tts-generation-webui.git") |
| |
|
| | |
| | update_dependencies() |
| |
|
| | def update_conda(): |
| | |
| | run_cmd("conda update -y -n base -c defaults conda") |
| |
|
| | def update_dependencies(): |
| | |
| | os.chdir("tts-generation-webui") |
| | run_cmd("git pull") |
| | run_cmd("pip install -r requirements.txt") |
| | run_cmd("python update.py") |
| | os.chdir(script_dir) |
| |
|
| | |
| | |
| |
|
| | def run_model(): |
| | os.chdir("tts-generation-webui") |
| | run_cmd("python server.py") |
| |
|
| |
|
| | if __name__ == "__main__": |
| | |
| | check_env() |
| | |
| | |
| | parser = argparse.ArgumentParser() |
| | parser.add_argument("--update", action="store_true", help="Update the web UI.") |
| | args = parser.parse_args() |
| |
|
| | if args.update: |
| | update_dependencies() |
| | else: |
| | |
| | if not os.path.exists("tts-generation-webui/"): |
| | install_dependencies() |
| | os.chdir(script_dir) |
| |
|
| | |
| | run_model() |
| |
|