Update Gpt-Sovits.py
Browse files- Gpt-Sovits.py +39 -11
Gpt-Sovits.py
CHANGED
|
@@ -124,22 +124,50 @@ def install_dependencies():
|
|
| 124 |
def NPS():
|
| 125 |
print("启动NPS")
|
| 126 |
os.system(f"/tmp/code/nps-Copy1/npc -server={NPS_server} -vkey={NPS_key} -type=tcp")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
def run_ngrok():
|
| 128 |
print('-----执行ngrok-------')
|
|
|
|
|
|
|
| 129 |
commands = [
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
]
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
while True:
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
time.sleep(10)
|
| 142 |
-
|
|
|
|
| 143 |
threading.Thread(target=run_ngrok, daemon=True).start()
|
| 144 |
subprocess.run(['npm', 'install', '-g','localtunnel'], check=True)
|
| 145 |
os.chdir(folder_path)
|
|
|
|
| 124 |
def NPS():
|
| 125 |
print("启动NPS")
|
| 126 |
os.system(f"/tmp/code/nps-Copy1/npc -server={NPS_server} -vkey={NPS_key} -type=tcp")
|
| 127 |
+
import subprocess
|
| 128 |
+
import threading
|
| 129 |
+
import time
|
| 130 |
+
|
| 131 |
def run_ngrok():
|
| 132 |
print('-----执行ngrok-------')
|
| 133 |
+
|
| 134 |
+
# 定义要执行的命令
|
| 135 |
commands = [
|
| 136 |
+
"curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc | tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null",
|
| 137 |
+
"echo 'deb https://ngrok-agent.s3.amazonaws.com buster main' | tee /etc/apt/sources.list.d/ngrok.list",
|
| 138 |
+
"apt update",
|
| 139 |
+
"apt install -y ngrok"
|
| 140 |
+
]
|
| 141 |
+
|
| 142 |
+
# 执行每个命令
|
| 143 |
+
for command in commands:
|
| 144 |
+
try:
|
| 145 |
+
print(f"执行命令: {command}")
|
| 146 |
+
subprocess.run(command, shell=True, check=True)
|
| 147 |
+
except subprocess.CalledProcessError as e:
|
| 148 |
+
print(f"命令执行失败: {e}")
|
| 149 |
+
return # 出现错误时,停止执行后续操作
|
| 150 |
+
|
| 151 |
+
# 添加 ngrok 的认证令牌
|
| 152 |
+
try:
|
| 153 |
+
print("添加 ngrok 认证令牌")
|
| 154 |
+
subprocess.run(['ngrok', 'config', 'add-authtoken', '2sWuZRgGWJHAgUC8dYumdkMe9Ma_3scefrNvGn1Qitmwb3g2n'], check=True)
|
| 155 |
+
except subprocess.CalledProcessError as e:
|
| 156 |
+
print(f"添加认证令牌失败: {e}")
|
| 157 |
+
return
|
| 158 |
+
|
| 159 |
+
# 启动 ngrok
|
| 160 |
while True:
|
| 161 |
+
try:
|
| 162 |
+
print("启动 ngrok http")
|
| 163 |
+
subprocess.run(['ngrok', 'http', '--url=polecat-neutral-certainly.ngrok-free.app', '9880'], check=True)
|
| 164 |
+
time.sleep(10) # 间隔 10 秒后再次尝试
|
| 165 |
+
except subprocess.CalledProcessError as e:
|
| 166 |
+
print(f"ngrok 启动失败: {e}")
|
| 167 |
+
# break # 如果失败,则退出循环
|
| 168 |
time.sleep(10)
|
| 169 |
+
|
| 170 |
+
# 启动线程
|
| 171 |
threading.Thread(target=run_ngrok, daemon=True).start()
|
| 172 |
subprocess.run(['npm', 'install', '-g','localtunnel'], check=True)
|
| 173 |
os.chdir(folder_path)
|