forked from PlayVoice/whisper-vits-svc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6857d54
commit 7ccf1f2
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from inference.infer_tool_grad import VitsSvc | ||
import gradio as gr | ||
import os | ||
|
||
class VitsGradio: | ||
def __init__(self): | ||
self.so = VitsSvc() | ||
self.lspk = [] | ||
self.modelPaths = [] | ||
for root,dirs,files in os.walk("checkpoints"): | ||
for dir in dirs: | ||
self.modelPaths.append(dir) | ||
with gr.Blocks() as self.Vits: | ||
with gr.Tab("VoiceConversion"): | ||
with gr.Row(visible=False) as self.VoiceConversion: | ||
with gr.Column(): | ||
with gr.Row(): | ||
with gr.Column(): | ||
self.srcaudio = gr.Audio(label = "输入音频") | ||
self.btnVC = gr.Button("说话人转换") | ||
with gr.Column(): | ||
self.dsid = gr.Dropdown(label = "目标角色", choices = self.lspk) | ||
self.tran = gr.Slider(label = "升降调", maximum = 60, minimum = -60, step = 1, value = 0) | ||
self.th = gr.Slider(label = "切片阈值", maximum = 32767, minimum = -32768, step = 0.1, value = -40) | ||
with gr.Row(): | ||
self.VCOutputs = gr.Audio() | ||
self.btnVC.click(self.so.inference, inputs=[self.srcaudio,self.dsid,self.tran,self.th], outputs=[self.VCOutputs]) | ||
with gr.Tab("SelectModel"): | ||
with gr.Column(): | ||
modelstrs = gr.Dropdown(label = "模型", choices = self.modelPaths, value = self.modelPaths[0], type = "value") | ||
devicestrs = gr.Dropdown(label = "设备", choices = ["cpu","cuda"], value = "cpu", type = "value") | ||
btnMod = gr.Button("载入模型") | ||
btnMod.click(self.loadModel, inputs=[modelstrs,devicestrs], outputs = [self.dsid,self.VoiceConversion]) | ||
|
||
def loadModel(self, path, device): | ||
self.lspk = [] | ||
self.so.set_device(device) | ||
self.so.loadCheckpoint(path) | ||
for spk, sid in self.so.hps.spk.items(): | ||
self.lspk.append(spk) | ||
VChange = gr.update(visible = True) | ||
SDChange = gr.update(choices = self.lspk, value = self.lspk[0]) | ||
return [SDChange,VChange] | ||
|
||
grVits = VitsGradio() | ||
|
||
grVits.Vits.launch() |