Update server.py
Browse files
server.py
CHANGED
|
@@ -7,6 +7,7 @@ import threading
|
|
| 7 |
import time
|
| 8 |
import psutil
|
| 9 |
import socket
|
|
|
|
| 10 |
env = os.environ.copy()
|
| 11 |
|
| 12 |
|
|
@@ -82,6 +83,7 @@ with open(file_path, 'w', encoding='utf-8') as file:
|
|
| 82 |
print(f"数据已成功写入 {file_path}")
|
| 83 |
# 安装环境
|
| 84 |
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "openi", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"])
|
|
|
|
| 85 |
# pip install -U gradio
|
| 86 |
# subprocess.run([sys.executable, "-m", "pip", "install", "-U", "LangSegment"])
|
| 87 |
#pip install LangSegment
|
|
@@ -90,6 +92,14 @@ subprocess.run([sys.executable, "-m", "pip", "install", "-U", "openi", "-i", "ht
|
|
| 90 |
# time.sleep(10) # 每次迭代暂停1秒
|
| 91 |
|
| 92 |
# threading.Thread(target=AA).start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
def download_and_extract_gpt_sovits():
|
| 94 |
if not os.path.exists('/home/aistudio/work/GPT-SoVITS'):
|
| 95 |
# subprocess.run(['openi', 'dataset', 'download', 'qilan2/SD-QL', 'GPT-SoVITS2.zip', '--cluster', 'NPU', '--save_path', '/home/aistudio'])
|
|
@@ -161,11 +171,11 @@ def run_api_script():
|
|
| 161 |
if is_port_open(9880): # 检查端口 9880 是否在监听
|
| 162 |
print("api.py 正在运行,不需要安装依赖。")
|
| 163 |
|
| 164 |
-
# 停止这个正在运行的进程
|
| 165 |
-
for proc in psutil.process_iter(attrs=['pid', 'name']):
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
|
| 170 |
else:
|
| 171 |
print("api.py 未能成功启动,需要安装依赖。")
|
|
|
|
| 7 |
import time
|
| 8 |
import psutil
|
| 9 |
import socket
|
| 10 |
+
import openi
|
| 11 |
env = os.environ.copy()
|
| 12 |
|
| 13 |
|
|
|
|
| 83 |
print(f"数据已成功写入 {file_path}")
|
| 84 |
# 安装环境
|
| 85 |
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "openi", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"])
|
| 86 |
+
os.system('apt install ffmpeg -y')
|
| 87 |
# pip install -U gradio
|
| 88 |
# subprocess.run([sys.executable, "-m", "pip", "install", "-U", "LangSegment"])
|
| 89 |
#pip install LangSegment
|
|
|
|
| 92 |
# time.sleep(10) # 每次迭代暂停1秒
|
| 93 |
|
| 94 |
# threading.Thread(target=AA).start()
|
| 95 |
+
if os.path.exists('/root/nltk_data') and os.path.isdir(folder_path):
|
| 96 |
+
print(f"文件夹 '/root/nltk_data' 存在。")
|
| 97 |
+
else:
|
| 98 |
+
print(f"文件夹 '/root/nltk_data' 不存在。")
|
| 99 |
+
os.system("rm -r /home/aistudio/nltk_data.zip")
|
| 100 |
+
openi.download_file(repo_id="qilan2/SD-QL",file="nltk_data.zip",cluster="NPU",save_path="/home/aistudio/",force=False)
|
| 101 |
+
os.system("unzip /home/aistudio/nltk_data.zip -d /root/")
|
| 102 |
+
os.system("rm -r /home/aistudio/nltk_data.zip")
|
| 103 |
def download_and_extract_gpt_sovits():
|
| 104 |
if not os.path.exists('/home/aistudio/work/GPT-SoVITS'):
|
| 105 |
# subprocess.run(['openi', 'dataset', 'download', 'qilan2/SD-QL', 'GPT-SoVITS2.zip', '--cluster', 'NPU', '--save_path', '/home/aistudio'])
|
|
|
|
| 171 |
if is_port_open(9880): # 检查端口 9880 是否在监听
|
| 172 |
print("api.py 正在运行,不需要安装依赖。")
|
| 173 |
|
| 174 |
+
# # 停止这个正在运行的进程
|
| 175 |
+
# for proc in psutil.process_iter(attrs=['pid', 'name']):
|
| 176 |
+
# if "api.py" in proc.info['name']:
|
| 177 |
+
# stop_process(proc.info['pid'])
|
| 178 |
+
# break
|
| 179 |
|
| 180 |
else:
|
| 181 |
print("api.py 未能成功启动,需要安装依赖。")
|