Update server.py
Browse files
server.py
CHANGED
|
@@ -3,6 +3,14 @@ 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,21 +26,24 @@ def download_and_extract_gpt_sovits():
|
|
| 18 |
subprocess.run(['wget','-O','/home/aistudio/work/GPT-SoVITS/api.py', 'https://hf-mirror.com/datasets/Qi28/aistudio_TTS/resolve/main/api.py'])
|
| 19 |
else:
|
| 20 |
print('GPT-SoVITS 文件夹已存在,无需下载和解压.')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
download_and_extract_gpt_sovits()
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
subprocess.run(['wget','-O','/home/aistudio/activate_port.py', 'https://hf-mirror.com/datasets/Qi28/aistudio_TTS/resolve/main/activate_port.py'])
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
env = os.environ.copy()
|
| 30 |
-
|
| 31 |
os.chdir('/home/aistudio/work/GPT-SoVITS')
|
| 32 |
# os.system("echo 'y' | sh install.sh")
|
| 33 |
# subprocess.run(['npm', 'install', '-g', 'localtunnel'])
|
| 34 |
# subprocess.run(['pip', 'install', '-r','requirements.txt'])
|
| 35 |
# subprocess.run(['pip', 'install', '-r','requirements.txt'])
|
| 36 |
-
|
| 37 |
subprocess.run(['python', '/home/aistudio/activate_port.py', '7860'], env=env)
|
| 38 |
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"')
|
|
|
|
| 3 |
import subprocess
|
| 4 |
import sys
|
| 5 |
import json
|
| 6 |
+
env = os.environ.copy()
|
| 7 |
+
|
| 8 |
+
port_and_commands = [
|
| 9 |
+
(7860, "-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"),
|
| 10 |
+
(7861, "-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 7861")
|
| 11 |
+
]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
|
| 15 |
# 安装环境
|
| 16 |
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "openi", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"])
|
|
|
|
| 26 |
subprocess.run(['wget','-O','/home/aistudio/work/GPT-SoVITS/api.py', 'https://hf-mirror.com/datasets/Qi28/aistudio_TTS/resolve/main/api.py'])
|
| 27 |
else:
|
| 28 |
print('GPT-SoVITS 文件夹已存在,无需下载和解压.')
|
| 29 |
+
def run_subprocesses(port_and_commands):
|
| 30 |
+
for port, command in port_and_commands:
|
| 31 |
+
env = os.environ.copy()
|
| 32 |
+
activate_port_cmd = ['python', '/home/aistudio/activate_port.py', str(port)]
|
| 33 |
+
subprocess.run(activate_port_cmd, env=env)
|
| 34 |
|
| 35 |
+
api_args = command.split()
|
| 36 |
+
api_cmd = ['python', '/home/aistudio/work/GPT-SoVITS/api.py'] + api_args
|
| 37 |
+
subprocess.run(api_cmd, env=env)
|
| 38 |
|
| 39 |
download_and_extract_gpt_sovits()
|
| 40 |
+
subprocess.run(['rm','/home/aistudio/activate_port.py'])
|
| 41 |
+
subprocess.run(['wget','-O','/home/aistudio/activate_port.py', 'https://hf-mirror.com/datasets/Qi28/aistudio_TTS/resolve/main/activate_port.py'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
os.chdir('/home/aistudio/work/GPT-SoVITS')
|
| 43 |
# os.system("echo 'y' | sh install.sh")
|
| 44 |
# subprocess.run(['npm', 'install', '-g', 'localtunnel'])
|
| 45 |
# subprocess.run(['pip', 'install', '-r','requirements.txt'])
|
| 46 |
# subprocess.run(['pip', 'install', '-r','requirements.txt'])
|
| 47 |
+
run_subprocesses(port_and_commands)
|
| 48 |
subprocess.run(['python', '/home/aistudio/activate_port.py', '7860'], env=env)
|
| 49 |
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"')
|