NeoPy commited on
Commit
a58a60d
·
verified ·
1 Parent(s): 31a4e37

Update tabs/infer/infer.py

Browse files
Files changed (1) hide show
  1. tabs/infer/infer.py +16 -8
tabs/infer/infer.py CHANGED
@@ -15,6 +15,8 @@ def get_current_models(models_dir):
15
  logger.error(f"Error accessing models directory: {e}\n{format_exc()}")
16
  raise gr.Error(f"Failed to list models. Check directory permissions: {e}")
17
 
 
 
18
 
19
 
20
  def inference_tab(status_message, rvc_model):
@@ -44,13 +46,19 @@ def inference_tab(status_message, rvc_model):
44
 
45
  with gr.Group():
46
  with gr.Row(equal_height=True):
47
- with gr.Column(visible=True, variant="panel", scale=1):
48
- song_input = gr.Textbox(
49
- label="Song Input",
50
- placeholder="Enter a YouTube link or local file path",
51
- lines=1
52
- )
53
-
 
 
 
 
 
 
54
  with gr.Accordion("RVC Settings", open=False):
55
  with gr.Row(equal_height=True):
56
  with gr.Column(variant="panel", scale=1):
@@ -87,7 +95,7 @@ def inference_tab(status_message, rvc_model):
87
  inst_gain = gr.Slider(-20, 20, value=0, step=1, label="Instrumental Gain (dB)")
88
 
89
  with gr.Row(equal_height=True):
90
- keep_files = gr.Checkbox(label="Keep Intermediate Files", value=True)
91
  vocal_only = gr.Checkbox(label="Vocal-Only Conversion", value=False)
92
 
93
  with gr.Row(equal_height=True):
 
15
  logger.error(f"Error accessing models directory: {e}\n{format_exc()}")
16
  raise gr.Error(f"Failed to list models. Check directory permissions: {e}")
17
 
18
+ def swap_visibility():
19
+ return gr.update(visible=True), gr.update(visible=False), gr.update(value=''), gr.update(value=None)
20
 
21
 
22
  def inference_tab(status_message, rvc_model):
 
46
 
47
  with gr.Group():
48
  with gr.Row(equal_height=True):
49
+ with gr.Column() as yt_link_col:
50
+ song_input = gr.Text(label='Song input', info='Link to a song on YouTube or full path to a local file. For file upload, click the button below.')
51
+ show_file_upload_button = gr.Button('Upload file instead?')
52
+
53
+ with gr.Column(visible=False) as file_upload_col:
54
+ local_file = gr.Audio(label='Audio file')
55
+
56
+ show_yt_link_button = gr.Button('Paste YouTube link instead?')
57
+ song_input_file.upload(process_file_upload, inputs=[song_input_file], outputs=[local_file, song_input])
58
+
59
+ show_file_upload_button.click(swap_visibility, outputs=[file_upload_col, yt_link_col, song_input, local_file])
60
+ show_yt_link_button.click(swap_visibility, outputs=[yt_link_col, file_upload_col, song_input, local_file])
61
+
62
  with gr.Accordion("RVC Settings", open=False):
63
  with gr.Row(equal_height=True):
64
  with gr.Column(variant="panel", scale=1):
 
95
  inst_gain = gr.Slider(-20, 20, value=0, step=1, label="Instrumental Gain (dB)")
96
 
97
  with gr.Row(equal_height=True):
98
+ keep_files = gr.Checkbox(label="Keep Intermediate Files", value=False, visible=False)
99
  vocal_only = gr.Checkbox(label="Vocal-Only Conversion", value=False)
100
 
101
  with gr.Row(equal_height=True):