mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-10-07 07:14:52 +08:00
Output history
This commit is contained in:
parent
d6f2fba666
commit
45fd28cf25
@ -356,29 +356,60 @@ SoVITS_names,GPT_names = get_weights_names()
|
|||||||
|
|
||||||
#region 输出音频历史记录相关
|
#region 输出音频历史记录相关
|
||||||
output_history =[]
|
output_history =[]
|
||||||
history_max_num = 12
|
history_max_num = 20
|
||||||
|
|
||||||
|
def sync_output_history_to_checkbox_audio():
|
||||||
|
checkbox_result = []
|
||||||
|
audio_result = []
|
||||||
|
for item in output_history:
|
||||||
|
label = item['label']
|
||||||
|
if len(label)>15:
|
||||||
|
label=label[:15]+'...'
|
||||||
|
checkbox_result.append(gr.update(label=label,value=False))
|
||||||
|
audio_result.append(gr.Audio.update(value=item['value']))
|
||||||
|
for _ in range(len(audio_result),history_max_num):
|
||||||
|
checkbox_result.append(gr.Checkbox.update(label="",value=False))
|
||||||
|
audio_result.append(gr.Audio.update(value = None))
|
||||||
|
return [*checkbox_result,*audio_result]
|
||||||
|
|
||||||
def add_to_history(audio,input_text):
|
def add_to_history(audio,input_text):
|
||||||
result = []
|
if(audio is None or audio[1] is not None):
|
||||||
#TODO change to audio type
|
if len(output_history) == history_max_num:
|
||||||
# if len(textbox_list_value) == history_max_num:
|
output_history.pop()
|
||||||
# output_history.pop()
|
output_history.insert(0,{'value':audio,'label':input_text})
|
||||||
# output_history.insert(0,text)
|
|
||||||
# for _ in range(history_max_num):
|
|
||||||
# result.append(gr.Textbox())
|
|
||||||
# for index,value in enumerate(output_history):
|
|
||||||
# result[index]._constructor_args[0]['value'] =value
|
|
||||||
|
|
||||||
return result
|
return [*sync_output_history_to_checkbox_audio()]
|
||||||
|
|
||||||
|
def clear_history():
|
||||||
|
global output_history
|
||||||
|
output_history = []
|
||||||
|
checkbox_result = []
|
||||||
|
audio_result = []
|
||||||
|
for _ in range(history_max_num):
|
||||||
|
checkbox_result.append(gr.Checkbox.update(label="",value=False))
|
||||||
|
audio_result.append(gr.Audio.update(value = None))
|
||||||
|
return [*checkbox_result,*audio_result]
|
||||||
|
|
||||||
def shown_audio_num_change(audio_num):
|
def shown_audio_num_change(audio_num):
|
||||||
audio_numr = int(audio_num)
|
audio_num = int(audio_num)
|
||||||
result = []
|
audio_result = []
|
||||||
|
checkbox_result = []
|
||||||
for _ in range(audio_num):
|
for _ in range(audio_num):
|
||||||
result.append(gr.Audio(visible=True))
|
audio_result.append(gr.Audio.update(visible=True))
|
||||||
|
checkbox_result.append(gr.update(visible=True))
|
||||||
for _ in range(audio_num,history_max_num):
|
for _ in range(audio_num,history_max_num):
|
||||||
result.append(gr.Audio(visible=False))
|
audio_result.append(gr.Audio.update(visible=False))
|
||||||
return result
|
checkbox_result.append(gr.update(visible=False))
|
||||||
|
return [*checkbox_result,*audio_result]
|
||||||
|
|
||||||
|
def delete_selected_history(*selected_list):
|
||||||
|
global output_history
|
||||||
|
print(f"!!!!!!!!{selected_list}")
|
||||||
|
for i in reversed(range(len(output_history))):
|
||||||
|
if(selected_list[i]):
|
||||||
|
output_history.pop(i)
|
||||||
|
print(f"!!!!{output_history}")
|
||||||
|
return [*sync_output_history_to_checkbox_audio()]
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
with gr.Blocks(title="GPT-SoVITS WebUI") as app:
|
with gr.Blocks(title="GPT-SoVITS WebUI") as app:
|
||||||
@ -415,19 +446,26 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
|
|||||||
[output],
|
[output],
|
||||||
)
|
)
|
||||||
history_audio = []
|
history_audio = []
|
||||||
|
history_checkbox = []
|
||||||
with gr.Accordion("生成历史"):
|
with gr.Accordion("生成历史"):
|
||||||
shown_audio_num = gr.Slider(0,12,8,step=1,interactive=True)
|
with gr.Row():
|
||||||
with gr.Group():
|
shown_audio_num = gr.Slider(1,20,history_max_num,step=1,interactive=True,label="记录显示数量")
|
||||||
|
add_history_button = gr.Button("添加当前音频记录",variant="primary")
|
||||||
|
delete_select_history_button = gr.Button("删除选择的记录")
|
||||||
|
clear_history_button = gr.Button("清空记录")
|
||||||
|
index=0
|
||||||
|
while(index<history_max_num):
|
||||||
|
index+=5
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
for _ in range(4):
|
for _ in range(5):
|
||||||
history_audio.append(gr.Audio(label=""))
|
with gr.Group():
|
||||||
with gr.Row():
|
history_checkbox.append(gr.Checkbox(interactive=True,show_label=False,label=""))
|
||||||
for _ in range(4):
|
history_audio.append(gr.Audio(label=""))
|
||||||
history_audio.append(gr.Audio(label=""))
|
|
||||||
with gr.Row():
|
shown_audio_num.change(shown_audio_num_change,[shown_audio_num],[*history_checkbox,*history_audio])
|
||||||
for _ in range(4):
|
add_history_button.click(add_to_history,[output,text],[*history_checkbox,*history_audio])
|
||||||
history_audio.append(gr.Audio(label=""))
|
delete_select_history_button.click(delete_selected_history,[*history_checkbox],[*history_checkbox,*history_audio])
|
||||||
|
clear_history_button.click(clear_history,outputs=[*history_checkbox,*history_audio])
|
||||||
gr.Markdown(value=i18n("文本切分工具。太长的文本合成出来效果不一定好,所以太长建议先切。合成会根据文本的换行分开合成再拼起来。"))
|
gr.Markdown(value=i18n("文本切分工具。太长的文本合成出来效果不一定好,所以太长建议先切。合成会根据文本的换行分开合成再拼起来。"))
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
text_inp = gr.Textbox(label=i18n("需要合成的切分前文本"),value="")
|
text_inp = gr.Textbox(label=i18n("需要合成的切分前文本"),value="")
|
||||||
|
5
go-inference.bat
Normal file
5
go-inference.bat
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
call %CONDA_PREFIX%\Scripts\activate.bat %CONDA_PREFIX%
|
||||||
|
call conda activate GPTSoVits
|
||||||
|
cd /d %~dp0
|
||||||
|
python .\GPT_SoVITS\inference_webui.py
|
||||||
|
pause
|
Loading…
x
Reference in New Issue
Block a user