Blane187 commited on
Commit
4403ac2
·
verified ·
1 Parent(s): 3e8e44c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -26
app.py CHANGED
@@ -1,11 +1,29 @@
1
  import gradio as gr
2
  import os, sys
3
  from colorama import Fore
4
-
5
  now_dir = os.getcwd()
6
  sys.path.append(now_dir)
7
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  # Function to detect the .pth and .index files
10
  def detect_files(model_name):
11
  model_dir = f"{now_dir}/assets/weights/{model_name}"
@@ -72,30 +90,41 @@ def process_audio(model_name, pitch, input_path, f0_method, save_as, index_rate,
72
  return "Error in processing audio.", None
73
 
74
  # Gradio interface
75
- with gr.Blocks() as demo:
76
- gr.Markdown("# 🔊 **LISTEN TO YOUR MODEL**")
77
-
78
- model_name = gr.Textbox(label="Model Name", value="Ren")
79
- pitch = gr.Slider(minimum=-12, maximum=12, step=1, label="Pitch", value=0)
80
- input_path = gr.Dropdown(label="",choices=show_available('audios'),value='',interactive=True)
81
- f0_method = gr.Radio(choices=["rmvpe", "pm", "crepe"], label="F0 Method", value="rmvpe")
82
- save_as = gr.Textbox(label="Save As", value="/content/RVC/audios/cli_output.wav")
83
- index_rate = gr.Slider(minimum=0, maximum=1, step=0.01, label="Index Rate", value=0.5)
84
- volume_normalization = gr.Slider(minimum=0, maximum=1, step=0.01, label="Volume Normalization", value=0)
85
- consonant_protection = gr.Slider(minimum=0, maximum=1, step=0.01, label="Consonant Protection", value=0.5)
86
-
87
- output_text = gr.Textbox(label="Output")
88
- output_audio = gr.Audio(label="Processed Audio")
89
-
90
- # Button to detect files
91
- detect_btn = gr.Button("Detect Files")
92
- detect_btn.click(fn=detect_files, inputs=[model_name], outputs=output_text)
93
-
94
- # Button to process the audio and return audio output
95
- submit_btn = gr.Button("Submit")
96
- submit_btn.click(fn=process_audio,
97
- inputs=[model_name, pitch, input_path, f0_method, save_as, index_rate, volume_normalization, consonant_protection],
98
- outputs=[output_text, output_audio])
99
-
 
 
 
 
 
 
 
 
 
 
 
100
  # Launch the app
101
  demo.launch()
 
1
  import gradio as gr
2
  import os, sys
3
  from colorama import Fore
4
+ from rvcsynch import download_from_url
5
  now_dir = os.getcwd()
6
  sys.path.append(now_dir)
7
 
8
 
9
+ def show_available(filepath,format=None):
10
+ if format:
11
+ print(f"Format: {format}")
12
+ files = []
13
+ for file in os.listdir(filepath):
14
+ if file.endswith(format):
15
+ print(f"Matches format: {file}")
16
+ files.append(file)
17
+ else:
18
+ print(f"Does not match format: {file}")
19
+ print(f"Matches: {files}")
20
+ if len(files) < 1:
21
+ return ['']
22
+ return files
23
+ if len(os.listdir(filepath)) < 1:
24
+ return ['']
25
+ return os.listdir(filepath)
26
+
27
  # Function to detect the .pth and .index files
28
  def detect_files(model_name):
29
  model_dir = f"{now_dir}/assets/weights/{model_name}"
 
90
  return "Error in processing audio.", None
91
 
92
  # Gradio interface
93
+ with gr.Blocks(theme="gradio/soft") as demo:
94
+ gr.Markdown("# 🔊 ** RVC GUI**")
95
+
96
+ with gr.Tabs():
97
+ model_name = gr.Textbox(label="Model Name", value="Ren")
98
+ pitch = gr.Slider(minimum=-12, maximum=12, step=1, label="Pitch", value=0)
99
+ with gr.Tab("Infernece"):
100
+ input_path = gr.Dropdown(label="",choices=show_available('audios'),value='',interactive=True)
101
+ f0_method = gr.Radio(choices=["rmvpe", "pm", "crepe"], label="F0 Method", value="rmvpe")
102
+ save_as = gr.Textbox(label="Save As", value="/content/RVC/audios/cli_output.wav")
103
+ index_rate = gr.Slider(minimum=0, maximum=1, step=0.01, label="Index Rate", value=0.5)
104
+ volume_normalization = gr.Slider(minimum=0, maximum=1, step=0.01, label="Volume Normalization", value=0)
105
+ consonant_protection = gr.Slider(minimum=0, maximum=1, step=0.01, label="Consonant Protection", value=0.5)
106
+
107
+ output_text = gr.Textbox(label="Output")
108
+ output_audio = gr.Audio(label="Processed Audio")
109
+ # Button to detect files
110
+ detect_btn = gr.Button("Detect Files")
111
+ detect_btn.click(fn=detect_files, inputs=[model_name], outputs=output_text)
112
+ # Button to process the audio and return audio output
113
+ submit_btn = gr.Button("Submit")
114
+ submit_btn.click(fn=process_audio,
115
+ inputs=[model_name, pitch, input_path, f0_method, save_as, index_rate, volume_normalization, consonant_protection],
116
+ outputs=[output_text, output_audio])
117
+
118
+ with gr.Tabs():
119
+ with gr.Tab("Download a model"):
120
+
121
+ url = gr.Texbox(label="url models...")
122
+ url_name = gr.Texbox(label="models names...")
123
+ download_fm = gr.Button("download model")
124
+ download_fm.click(fn=download_from_url, inputs=[url, url_name], outputs=url_name)
125
+
126
+
127
+
128
+
129
  # Launch the app
130
  demo.launch()