Update server.py
Browse files
server.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
import os
|
| 3 |
import subprocess
|
| 4 |
import sys
|
| 5 |
-
|
| 6 |
|
| 7 |
# 安装环境
|
| 8 |
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "openi", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"])
|
|
@@ -18,7 +18,33 @@ def download_and_extract_gpt_sovits():
|
|
| 18 |
else:
|
| 19 |
print('GPT-SoVITS 文件夹已存在,无需下载和解压.')
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
download_and_extract_gpt_sovits()
|
| 24 |
|
|
@@ -29,7 +55,8 @@ os.chdir('/home/aistudio/work/GPT-SoVITS')
|
|
| 29 |
# subprocess.run(['npm', 'install', '-g', 'localtunnel'])
|
| 30 |
# subprocess.run(['pip', 'install', '-r','requirements.txt'])
|
| 31 |
# subprocess.run(['pip', 'install', '-r','requirements.txt'])
|
| 32 |
-
subprocess.run(['python', '/home/aistudio/activate_port.py', '7860'])
|
|
|
|
| 33 |
|
| 34 |
# os.system("python api.py -p '7860' -d 'cpu'")
|
| 35 |
os.system('python /home/aistudio/work/GPT-SoVITS/api.py -s "/home/aistudio/work/tts1/奶油_e8_s152.pth" -g "/home/aistudio/work/tts1/奶油-e15.ckpt" -dr "/home/aistudio/work/tts1/涨粉.wav" -dt "有个十万播放的切片涨了四千涨了四五千的粉" -dl "zh" -d "cpu" -p "7860"')
|
|
|
|
| 2 |
import os
|
| 3 |
import subprocess
|
| 4 |
import sys
|
| 5 |
+
import json
|
| 6 |
|
| 7 |
# 安装环境
|
| 8 |
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "openi", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"])
|
|
|
|
| 18 |
else:
|
| 19 |
print('GPT-SoVITS 文件夹已存在,无需下载和解压.')
|
| 20 |
|
| 21 |
+
class Func:
|
| 22 |
+
@staticmethod
|
| 23 |
+
def register_port(*ports):
|
| 24 |
+
os.makedirs(".webide", exist_ok=True)
|
| 25 |
+
path = os.path.join(".webide", "proxy_config.json")
|
| 26 |
+
data = Func.load_json(path)
|
| 27 |
+
if "gradio" not in data:
|
| 28 |
+
data["gradio"] = {}
|
| 29 |
+
for port in ports:
|
| 30 |
+
data["gradio"][port] = int(port)
|
| 31 |
+
Func.write_json(path, data)
|
| 32 |
+
|
| 33 |
+
@staticmethod
|
| 34 |
+
def load_json(path):
|
| 35 |
+
if os.path.exists(path):
|
| 36 |
+
with open(path, "r", encoding="utf-8") as file:
|
| 37 |
+
return json.load(file)
|
| 38 |
+
return {}
|
| 39 |
+
|
| 40 |
+
@staticmethod
|
| 41 |
+
def write_json(path, data):
|
| 42 |
+
with open(path, "w") as file:
|
| 43 |
+
json.dump(data, file, ensure_ascii=False)
|
| 44 |
+
|
| 45 |
+
def activate_port(port):
|
| 46 |
+
Func.register_port(port)
|
| 47 |
+
print(f"Port {port} has been activated.")
|
| 48 |
|
| 49 |
download_and_extract_gpt_sovits()
|
| 50 |
|
|
|
|
| 55 |
# subprocess.run(['npm', 'install', '-g', 'localtunnel'])
|
| 56 |
# subprocess.run(['pip', 'install', '-r','requirements.txt'])
|
| 57 |
# subprocess.run(['pip', 'install', '-r','requirements.txt'])
|
| 58 |
+
# subprocess.run(['python', '/home/aistudio/activate_port.py', '7860'])
|
| 59 |
+
activate_port('7860')
|
| 60 |
|
| 61 |
# os.system("python api.py -p '7860' -d 'cpu'")
|
| 62 |
os.system('python /home/aistudio/work/GPT-SoVITS/api.py -s "/home/aistudio/work/tts1/奶油_e8_s152.pth" -g "/home/aistudio/work/tts1/奶油-e15.ckpt" -dr "/home/aistudio/work/tts1/涨粉.wav" -dt "有个十万播放的切片涨了四千涨了四五千的粉" -dl "zh" -d "cpu" -p "7860"')
|