config.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. elif torch.backends.mps.is_available():
  19. infer_device = "mps"
  20. else:
  21. infer_device = "cpu"
  22. webui_port_main = 9874
  23. webui_port_uvr5 = 9873
  24. webui_port_infer_tts = 9872
  25. webui_port_subfix = 9871
  26. api_port = 9880
  27. if infer_device == "cuda":
  28. gpu_name = torch.cuda.get_device_name(0)
  29. if (
  30. ("16" in gpu_name and "V100" not in gpu_name.upper())
  31. or "P40" in gpu_name.upper()
  32. or "P10" in gpu_name.upper()
  33. or "1060" in gpu_name
  34. or "1070" in gpu_name
  35. or "1080" in gpu_name
  36. ):
  37. is_half=False
  38. if(infer_device=="cpu"):is_half=False
  39. class Config:
  40. def __init__(self):
  41. self.sovits_path = sovits_path
  42. self.gpt_path = gpt_path
  43. self.is_half = is_half
  44. self.cnhubert_path = cnhubert_path
  45. self.bert_path = bert_path
  46. self.pretrained_sovits_path = pretrained_sovits_path
  47. self.pretrained_gpt_path = pretrained_gpt_path
  48. self.exp_root = exp_root
  49. self.python_exec = python_exec
  50. self.infer_device = infer_device
  51. self.webui_port_main = webui_port_main
  52. self.webui_port_uvr5 = webui_port_uvr5
  53. self.webui_port_infer_tts = webui_port_infer_tts
  54. self.webui_port_subfix = webui_port_subfix
  55. self.api_port = api_port