config.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import sys,os
  2. import torch
  3. # 推理用的指定模型
  4. sovits_path = ""
  5. gpt_path = ""
  6. is_half_str = os.environ.get("is_half", "True")
  7. is_half = True if is_half_str.lower() == 'true' else False
  8. is_share_str = os.environ.get("is_share","False")
  9. is_share= True if is_share_str.lower() == 'true' else False
  10. cnhubert_path = "GPT_SoVITS/pretrained_models/chinese-hubert-base"
  11. bert_path = "GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large"
  12. pretrained_sovits_path = "GPT_SoVITS/pretrained_models/s2G488k.pth"
  13. pretrained_gpt_path = "GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt"
  14. exp_root = "logs"
  15. python_exec = sys.executable or "python"
  16. if torch.cuda.is_available():
  17. infer_device = "cuda"
  18. else:
  19. infer_device = "cpu"
  20. webui_port_main = 9874
  21. webui_port_uvr5 = 9873
  22. webui_port_infer_tts = 9872
  23. webui_port_subfix = 9871
  24. api_port = 9880
  25. if infer_device == "cuda":
  26. gpu_name = torch.cuda.get_device_name(0)
  27. if (
  28. ("16" in gpu_name and "V100" not in gpu_name.upper())
  29. or "P40" in gpu_name.upper()
  30. or "P10" in gpu_name.upper()
  31. or "1060" in gpu_name
  32. or "1070" in gpu_name
  33. or "1080" in gpu_name
  34. ):
  35. is_half=False
  36. if(infer_device=="cpu"):is_half=False
  37. class Config:
  38. def __init__(self):
  39. self.sovits_path = sovits_path
  40. self.gpt_path = gpt_path
  41. self.is_half = is_half
  42. self.cnhubert_path = cnhubert_path
  43. self.bert_path = bert_path
  44. self.pretrained_sovits_path = pretrained_sovits_path
  45. self.pretrained_gpt_path = pretrained_gpt_path
  46. self.exp_root = exp_root
  47. self.python_exec = python_exec
  48. self.infer_device = infer_device
  49. self.webui_port_main = webui_port_main
  50. self.webui_port_uvr5 = webui_port_uvr5
  51. self.webui_port_infer_tts = webui_port_infer_tts
  52. self.webui_port_subfix = webui_port_subfix
  53. self.api_port = api_port