PlayVoice / whisper-vits-svc

Core Engine of Singing Voice Conversion & Singing Voice Clone
https://huggingface.co/spaces/maxmax20160403/sovits5.0
MIT License
2.57k stars 914 forks source link

一种推理任务的cpu并行处理 #99

Open KIKscanf opened 11 months ago

KIKscanf commented 11 months ago

import threading import time import os

定义一个函数,用来执行一个cmd命令,并打印出运行时间

def run_cmd(cmd): start = time.time() os.system(cmd) end = time.time() print(f"{cmd} took {end - start} seconds")

创建3个Thread对象,分别同时执行3个cmd命令

t1 = threading.Thread(target=run_cmd, args=("python whisper/inference.py -w test.wav -p test.ppg.npy",)) t2 = threading.Thread(target=run_cmd, args=("python hubert/inference.py -w test.wav -v test.vec.npy",)) t3 = threading.Thread(target=run_cmd, args=("python pitch/inference.py -w test.wav -p test.csv",))

启动3个线程

t1.start() t2.start() t3.start()

等待3个线程结束

t1.join() t2.join() t3.join() os.system("python svc_inference.py --config configs/base.yaml --model sovits5.0Yukino_merge.pth --spk ./data_svc/singer/Yukino.spk.npy --wave test.wav --ppg test.ppg.npy --vec test.vec.npy --pit test.csv --shift 0")

打印主线程结束的信息

print("svc finished")

终端执行python inferencenew.py